Hi! In my current Android project I need the abili...
# ktor
f
Hi! In my current Android project I need the ability to change server base url in runtime through UI. How can I change base request url asynchronously? Preferably I want to use it something like this:
Copy code
class KtorClientFactory(
    private val baseUrl: suspend () -> String,
) {

    fun create(): HttpClient = HttpClient(
        engine = OkHttpEngine(config = OkHttpConfig())
    ) {
        installDefaultRequest()
    }

    private fun HttpClientConfig<*>.installDefaultRequest() {
        install(DefaultRequest) {
            url {
                host = baseUrl() // Can't call suspend here. Want it to be called on each request
            }
        }
    }
}
f
you should use an interceptor
you can update your request dynamically each time if necessary
f
Thank you! It works as required
🙌 1