Fyodor Danilov
10/15/2024, 12:28 PMclass 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
}
}
}
}
François
10/15/2024, 12:34 PMFrançois
10/15/2024, 12:37 PMFyodor Danilov
10/15/2024, 12:46 PM