I have a database column that contains a value tha...
# ktor
k
I have a database column that contains a value that I need to add to my requests. The value is exposed as
Flow<String>
. Can I somehow "watch" the flow and update my ktor configuration on the fly if the value changes?
Copy code
fun createHttpClient(headerValue: Flow<String>): MyHttpClient {
    install(DefaultRequest) {
        header("X-my-header", "${headerValue.value}")
    }
}
a
You cannot mutate the client's configuration but you can create a new client with overridden configuration.
k
Ahh, OK! Thanks for letting me know. Is the creation considered an expensive operation? Or is the performance impact negligible? Theoretically, I can store the partial builder and only re-apply the last plugin installation for the custom header. And then recreate the client.
a
It's a kinda expensive operation. How often do you plan changing the configuration?