Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 677 Bytes

generic-requests.md

File metadata and controls

32 lines (26 loc) · 677 Bytes

Generic requests

A request context can be reused for different http methods without explicitly calling the httpGet or other functions for different http methods.

var variableMethod: Method = Method.GET

val response: Response = http(method = variableMethod) {
    host = "google.com"
    path = "/search"
    param {
        "q" to "iphone"
        "safe" to "off"
    }
}

or

var variableMethod: Method = Method.GET
val context : HttpContext.() -> Unit = {
    host = "google.com"
    path = "/search"
    param {
        "q" to "iphone"
        "safe" to "off"
    }
}

val response: Response = http(method = variableMethod, init = context)