hi all, I’m facing a small problem with the ktor c...
# ktor
h
hi all, I’m facing a small problem with the ktor client proxy configuration. my current setup is, that I’m using the apache engine in my ktor client, as I need a connection with credentials. But I have also a different problem. how I can also route connection differently for some hosts? So host1 should use the proxy settings and host2 don’t. I hope I can get some guidance here.
r
I’m not sure if I understand it correctly. But you could create two HttpClients and inject the ones you need. For example with Koin you could do something like this:
Copy code
val networkModule = module {
    factory(named("custom"))  { customEngineHttpClient() }
    factory(named("normal"))  { defaultEngineHttpClient() }
    //... other networking stuff
}

private fun customEngineHttpClient() =
    HttpClient {
        install(HttpCallValidator)
        install(JsonFeature) {
          //... KotlinXSerializer
        }
    }

private fun defaultEngineHttpClient() =
    HttpClient {
        install(HttpCallValidator)
        install(JsonFeature) {
          //... KotlinXSerializer
        }
    }
h
yes I could do that but hoped, I can do it without two clients :)