Skip to content

Client as a function

This example demonstrates using http4k as a client, to consume HTTP services. A client is just another HttpHandler.

Gradle setup

compile group: "org.http4k", name: "http4k-core", version: "3.255.0"


package cookbook.client_as_a_function

import org.http4k.client.JavaHttpClient
import org.http4k.core.HttpHandler
import org.http4k.core.Method
import org.http4k.core.Request

fun main() {

    val request = Request(Method.GET, "")

    val client: HttpHandler = JavaHttpClient()