Mohit Gurumukhani
08/20/2018, 8:28 PMval response = client.get<MyClass>(“<https://en.wikipedia.org/wiki/Main_Page”>)
This will return convert the returned Json to MyClass. However, this won’t allow us to get additional info such as return status code etc. Is there a way to get around this?Deactivated User
08/21/2018, 11:03 AMMohit Gurumukhani
08/21/2018, 3:41 PMval response = client.get<HttpResponse<Myclass>>(“<https://en.wikipedia.org/wiki/Main_Page”>)
Where MyClass defines serialized return type along with body maybe?gildor
08/22/2018, 5:57 AMDeactivated User
08/22/2018, 9:33 AMdata class HttpClientTypedResponse<T>(val response: HttpResponse, val instance: T) : HttpResponse by response
suspend inline fun <reified T> HttpClient.getTyped(
url: String = "<http://127.0.0.1:8080/>",
body: Any = EmptyContent,
noinline block: HttpRequestBuilder.() -> Unit = {}
): HttpClientTypedResponse<T> {
val call = call {
url(url)
method = HttpMethod.Get
this.body = body
block()
}
return HttpClientTypedResponse(call.response, call.receive())
}
Deactivated User
08/22/2018, 9:36 AMe5l
08/22/2018, 9:56 AM