Nikolai
04/16/2019, 12:46 PMe5l
04/16/2019, 1:06 PMokhttp
at okhttp
level.Nikolai
04/16/2019, 1:11 PMe5l
04/16/2019, 1:13 PMokhttp
instance in OkHttpConfig
Nikolai
04/16/2019, 1:22 PMe5l
04/16/2019, 1:23 PMtls
configuration for now.Nikolai
04/16/2019, 1:29 PMprivate val client = HttpClient {
expectSuccess = false
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
GlobalScope.launch(CoroutineContextProvider.provideContext()) {
try {
val call = client.request<HttpResponse> {
url {
protocol = serverProtocol
host = serverAddress
port = serverPort
encodedPath = requestEncodedPath
}
method = <http://HttpMethod.Post|HttpMethod.Post>
body = requestBody
for (currentPair:Pair<String, String> in requestHeaders) {
headers.append(currentPair.first, currentPair.second)
}
headers.append(apiVersionHeader, apiVersion)
for (currentPair:Pair<String, String> in parameters) {
parameter(currentPair.first, currentPair.second)
}
}
requestResponseHandler(call, call.readText())
} catch (requestException:Exception) {
requestExceptionHandler(requestException)
}
}
This client initialization in common module and sending requests api.
Is there any way how I can still use it, but may be provide some config for OkHttp, from actual class implementations? Without rewriting too much code?e5l
04/16/2019, 2:02 PMHttpClient
in expect fun
. Also you can search for the multiplatform DI framework.Nikolai
04/16/2019, 2:09 PMbrian
04/16/2019, 5:47 PM