Mario Andhika
03/08/2025, 3:43 AMdefaultRequest
config but only for a specific service, but all using the same HttpClient? At the moment I’m using prepareRequest
instead, in this manner:
suspend fun buildRequest(
httpMethod: HttpMethod,
endpoint: String,
queryParams: List<Pair<String, String>> = emptyList(),
body: String? = null
): HttpStatement {
return httpClient.prepareRequest {
url("${baseUrl}${endpoint}")
queryParams.forEach { (key, values) ->
parameter(key, values)
}
method = httpMethod
basicAuth(apiKey, "") // These two lines and baseUrl are the same across the service
contentType(ContentType.Application.Json) //
body?.let { setBody(it) }
}
}
Is this a good idea?Cương Nguyễn
03/09/2025, 8:35 AMAleksei Tirman [JB]
03/10/2025, 8:57 AMDefaultRequest
plugin within a single HttpClient is not possible.