All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.connect.kafka.rest.HttpKafkaRest.kt Maven / Gradle / Ivy

There is a newer version: 5.35.3.0
Show newest version
package org.http4k.connect.kafka.rest

import org.http4k.client.JavaHttpClient
import org.http4k.connect.kafka.rest.v2.KafkaRestV2Action
import org.http4k.connect.kafka.rest.v3.KafkaRestV3Action
import org.http4k.core.Credentials
import org.http4k.core.HttpHandler
import org.http4k.core.Uri
import org.http4k.core.then
import org.http4k.filter.ClientFilters.BasicAuth
import org.http4k.filter.ClientFilters.SetHostFrom

/**
 * Standard HTTP implementation of KafkaRest Proxy
 */
fun KafkaRest.Companion.Http(
    credentials: Credentials,
    baseUri: Uri,
    http: HttpHandler  = JavaHttpClient()
) = object : KafkaRest {
    private val http = BasicAuth(credentials)
        .then(SetHostFrom(baseUri))
        .then(http)

    override fun  invoke(action: KafkaRestV2Action) = action.toResult(this.http(action.toRequest()))
    override fun  invoke(action: KafkaRestV3Action) = action.toResult(this.http(action.toRequest()))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy