ursus
02/26/2023, 10:21 PMengine { ... }
block?
If it were somehow on the Engine object, then I'd get it, I'd just expect actual the Engine factory
...or do I have to expect actual both factory for Engine AND the engine block?CLOVIS
02/27/2023, 8:32 AMHttpClient
constructor is in commonursus
02/27/2023, 9:13 AMCLOVIS
02/27/2023, 9:15 AM// commonMain/kotlin/Client
fun createClient() = HttpClient {
install(Logging) { … }
install(ContentNegotiation) { … }
}
This worksursus
02/27/2023, 9:16 AMCLOVIS
02/27/2023, 9:17 AMursus
02/27/2023, 9:18 AMengine {
preconfigured = ...
}
actual createEngine(): HttpEngine
CLOVIS
02/27/2023, 9:20 AMHttpClientConfig<*>
which has your common configuration, and call it in your various actuals that add platform-specific config: https://gitlab.com/opensavvy/formulaide/-/blob/main/remote-client/src/commonMain/kotlin/Client.kt#L17HttpClientConfig<*>
is the receiver of the HttpClient {}
factory)ursus
02/27/2023, 9:24 AMCLOVIS
02/27/2023, 9:34 AMursus
02/27/2023, 9:35 AMokhttp.newBuilder()
doesCLOVIS
02/27/2023, 9:35 AMursus
02/27/2023, 9:36 AMCLOVIS
02/27/2023, 9:37 AMursus
02/27/2023, 9:39 AMCLOVIS
02/27/2023, 9:40 AMpreconfigured=
? In that case, you just have to pass the same object for both calls and they share the OkHttp instanceursus
02/27/2023, 9:41 AMCLOVIS
02/27/2023, 9:42 AMursus
02/27/2023, 9:43 AMinstall(httpClient)
val baseClient = HttpClient {
install(DefaultRequest)
install(ContentNegotiation)
}
val authedClient = HttpClient {
install(baseClient)
install(Auth)
}
but its the other way around 🙄