Kairo Client
Ktor-native outgoing HTTP requests from your Kairo application.
Installation
Section titled “Installation”Install kairo-client-feature.
You don’t need to install Ktor dependencies separately —
they’re included by default.
dependencies { implementation("com.highbeam.kairo:kairo-client-feature")}Create a separate Feature for each external integration.
Each ClientFeature manages its own Ktor HttpClient lifecycle
and registers it with DI under the given name.
class WeatherFeature : ClientFeature(httpClientName = "weather") { override val name: String = "Weather"
override val timeout: Duration = 5.seconds
override fun HttpClientConfig<*>.configure() { defaultRequest { url("https://api.weather.gov") userAgent("kairo (jeff@highbeam.com)") } }}The timeout property sets the request timeout for the client.
Use the configure() block to set default request parameters,
install Ktor plugins, or add custom headers.
Making requests
Section titled “Making requests”Inject the corresponding Ktor HttpClient by name
and use it to make requests.
@Named("weather") val weatherClient: HttpClient
val response = weatherClient.request { method = HttpMethod.Get url("/gridpoints/LWX/96,70/forecast")}return response.body()Multiple clients
Section titled “Multiple clients”Since each ClientFeature creates a separate HttpClient,
you can have as many as you need.
Each is registered under its httpClientName in DI
and can be injected independently.
Advanced usage
Section titled “Advanced usage”Refer to the Ktor client documentation for more advanced usage.