kohttp
  • Introduction
  • Core
    • Synchronous calls
      • GET
      • POST
      • PUT
      • HEAD
      • DELETE
      • PATCH
      • Generic requests
      • Upload files
    • Asynchronous calls
      • async GET
      • async POST
      • async PUT
      • async HEAD
      • async DELETE
      • async PATCH
      • async Generic requests
      • async Upload files
    • Response usage
    • Interceptors
    • Customisation
    • Experimental features
  • History
    • Changelog
Powered by GitBook
On this page

Was this helpful?

  1. Core
  2. Asynchronous calls

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.

var variableMethod: Method = Method.GET

val response: Deferred<Response> = httpAsync(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: Deferred<Response> = httpAsync(method = variableMethod, init = context)
Previousasync PATCHNextasync Upload files

Last updated 5 years ago

Was this helpful?