Hello! Can I have this configuration (JsonFeature,...
# server
g
Hello! Can I have this configuration (JsonFeature, serializersModule):
Copy code
private fun createHttpClient(enableNetworkLogs: Boolean) = HttpClient {
    install(JsonFeature) {
        serializer = KotlinxSerializer(kotlinx.serialization.json.Json {
            isLenient = true
            ignoreUnknownKeys = true
            serializersModule = SerializersModule { contextual(MyCustomSerializer) }
        })
    }
    if (enableNetworkLogs) {
        install(Logging) {
            logger = Logger.DEFAULT
            level = LogLevel.ALL
        }
    }
}
Applied only to a specific request (without creating a different client)
Copy code
suspend fun fetchData(): List<Something> = client.<configure specific serializersModule for this request>.get(...)
? Thanks for your time! ps: this is my ktor configuration for KMM commonModule. Maybe the question is in the wrong channel 😕 sorry in advance
r
Hi! Right now Ktor client doesn’t support configuration of JsonFeature per request. What is your use case?
g
let’s say I have an API (i can’t change it) that one of its methods returns a json that I need to transform, but I don’t want to use this rule for all endpoints. That’s why I asked if I could use just in a specific request. https://stackoverflow.com/q/66841466/1423773