Package-level declarations

Types

Link copied to clipboard
sealed class KAuthProvider

Defines how authentication headers are injected into every outgoing request.

Link copied to clipboard
data class KCacheConfig(val maxAgeSeconds: Long = 300, val maxEntries: Int = 100, val strategy: KCacheStrategy = KCacheStrategy.NetworkFirst)

Configuration for the in-memory HTTP response cache.

Link copied to clipboard

Cache strategy controlling when cached responses are used.

Link copied to clipboard
class KDefaultTokenRefresher(refreshUrl: String, getRefreshToken: suspend () -> String?, onTokenRefreshed: suspend (accessToken: String, refreshToken: String) -> Unit, onFailed: suspend () -> Unit, authProvider: KAuthProvider? = null) : KTokenRefresher

Default KTokenRefresher implementation provided by Kindling.

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

Configuration for buildKHttpClient.

Link copied to clipboard
sealed class KHttpException(message: String) : Exception

Sealed hierarchy of HTTP-related exceptions thrown by buildKHttpClient.

Link copied to clipboard
annotation class KMockEngineApi
Link copied to clipboard
data class KMockHandler(val method: HttpMethod, val path: String, val status: HttpStatusCode = HttpStatusCode.OK, val resolver: suspend (params: Map<String, String>, body: String?) -> Any?)

Represents a registered mock route handler.

Link copied to clipboard

Thread-safe singleton registry storing all KMockHandler entries.

Link copied to clipboard
data class KRequestInterceptor(val onResponse: suspend (HttpResponse) -> Unit? = null)

Hook for observing every response globally.

Link copied to clipboard
interface KTokenRefresher

Contract for automatic token refresh on 401 responses.

Properties

Link copied to clipboard
val mockJson: Json

Functions

Link copied to clipboard
fun HttpResponse.accept(vararg codes: HttpStatusCode): HttpResponse

Asserts the response status is one of codes.

Link copied to clipboard
fun FormBuilder.appendBytes(partName: String, bytes: ByteArray, contentType: String, fileName: String)

Appends raw ByteArray content to the multipart form.

Link copied to clipboard
fun FormBuilder.appendFile(partName: String, file: File, contentType: String = "application/octet-stream", fileName: String = file.name)

Appends a File to the multipart form with the given partName and contentType.

Link copied to clipboard
fun buildKHttpClient(config: KHttpConfig): HttpClient

Builds a pre-configured Ktor HttpClient following the Kindling convention.

Link copied to clipboard
fun buildKMockEngine(delayMs: Long = 300, apiPrefix: String = "/api"): MockEngine
Link copied to clipboard
inline fun <T> kMockHandler(method: HttpMethod, path: String, status: HttpStatusCode = HttpStatusCode.OK, noinline resolver: suspend (params: Map<String, String>, body: String?) -> T): KMockHandler

Reified helper to create a KMockHandler that captures the return type's serializer. This avoids reflective lookup and correctly handles generic types in the mock response.

Link copied to clipboard
inline fun <T> HttpRequestBuilder.setBodyJson(body: T)

Serialises body as JSON and sets Content-Type: application/json.

Link copied to clipboard
fun HttpRequestBuilder.setBodyMultipart(block: FormBuilder.() -> Unit)

Sets a multipart/form-data body on the request.