KHttpConfig

constructor(baseUrl: String, engine: HttpClientEngine? = null, connectTimeoutMs: Long, requestTimeoutMs: Long, logLevel: LogLevel = LogLevel.NONE, onClientError: (Int, String) -> Unit? = null, onServerError: (Int, String) -> Unit? = null, onSessionExpired: () -> Unit? = null, authPaths: List<String> = listOf("/auth/login", "/auth/register"), cookieStorage: CookiesStorage? = null, authProvider: KAuthProvider? = null, tokenRefresher: KTokenRefresher? = null, interceptor: KRequestInterceptor? = null, cacheConfig: KCacheConfig? = null)(source)

Parameters

baseUrl

Base URL prepended to every request (must end with /).

engine

Ktor engine. Defaults to platform default when null.

connectTimeoutMs

TCP connect timeout in milliseconds.

requestTimeoutMs

Full request timeout in milliseconds.

logLevel

Ktor LogLevel. Use LogLevel.NONE in production.

onClientError

Called on 4xx responses with status code + parsed message.

onServerError

Called on 5xx responses with status code + parsed message.

onSessionExpired

Called on 401 outside authPaths. Clear your session here.

authPaths

Path suffixes treated as auth endpoints (401 = wrong credentials).

cookieStorage

Optional CookiesStorage for cookie-based auth.

authProvider

Optional KAuthProvider injecting auth headers on every request. Also accepts KAuthProvider.Custom for global headers like trace IDs or app version — replaces the need for a separate request interceptor.

tokenRefresher

Optional KTokenRefresher for automatic 401 token refresh. Use KDefaultTokenRefresher for standard Bearer JWT flows, or implement KTokenRefresher directly for custom logic.

interceptor

Optional KRequestInterceptor for global response-side hooks (analytics, logging). Request-side mutations belong in authProvider.

cacheConfig

Optional KCacheConfig for in-memory GET response caching, backed by dev.kindling.utils.CircularBuffer and dev.kindling.utils.KMap.