jean
06/10/2020, 6:44 PMHttpClient(CIO) {
defaultRequest {
url {
host = "<https://my.host.com>"
port = 443
}
}
install(JsonFeature) {
serializer = GsonSerializer()
}
}
I does not work when I try to use it with client.get<ApiResponse<Character>>("/endpoint")
Am I doing anything wrong?jean
06/11/2020, 8:31 AMprivate suspend fun get(path: String, parameters: Map<String, String>): SomeType {
return client.get(
scheme = "https",
host = "<http://my.host.com|my.host.com>",
port = 8080,
path = path
) { addParameters(parameters) }
}
and call it like get("my/path", parameters)
Nicolas Chevalier
06/11/2020, 1:42 PMprotected fun HttpRequestBuilder.apiUrl(path: String) {
url {
takeFrom(baseUrl)
encodedPath = path
}
}
and use it like this:
val response: HttpResponse = <http://client.post|client.post> {
apiUrl(path)
addParameters(parameters)
}
Nicolas Chevalier
06/11/2020, 1:42 PMjean
06/12/2020, 10:26 AM