kohttp
Search…
async Generic requests
A request context can be reused for different http methods without explicitly calling the httpGetAsync or other functions for different http methods.
1
var variableMethod: Method = Method.GET
2
3
val response: Deferred<Response> = httpAsync(method = variableMethod) {
4
host = "google.com"
5
path = "/search"
6
param {
7
"q" to "iphone"
8
"safe" to "off"
9
}
10
}
Copied!
or
1
var variableMethod: Method = Method.GET
2
val context : HttpContext.() -> Unit = {
3
host = "google.com"
4
path = "/search"
5
param {
6
"q" to "iphone"
7
"safe" to "off"
8
}
9
}
10
11
val response: Deferred<Response> = httpAsync(method = variableMethod, init = context)
Copied!
Last modified 1yr ago
Copy link