Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
data class ErrorStatus(val code: Int, val message: String, val details: String? = null)
Link copied to clipboard
data class Image(val category: String, val path: String, val author: String)
Link copied to clipboard
class ImgRes
Link copied to clipboard
data class MediaApiClient(val timeout: Timeout = Timeout.DEFAULT, val retry: Retry = Retry.DEFAULT) : AutoCloseable
Link copied to clipboard
Link copied to clipboard
data class Retry(val attempts: Int, val maxDelay: Duration)
Link copied to clipboard
data class Timeout(val connection: Duration, val read: Duration, val write: Duration)
Link copied to clipboard
data class Video(val description: String, val sources: List<String>, val subtitle: String, val thumb: String, val title: String, val poster: String? = null)
Link copied to clipboard
class VideoRes

Properties

Link copied to clipboard
Link copied to clipboard
val customSSLFactory: SSLFactory
Link copied to clipboard
val json: Json

Common JSON instance for serde of JSON data.

Link copied to clipboard
val log: KLogger

Functions

Link copied to clipboard
Link copied to clipboard
expect fun httpClient(name: String = "Api Client", timeout: Timeout = Timeout.DEFAULT, retry: Retry = Retry.DEFAULT, httpLogger: KLogger = log, config: HttpClientConfig<*>.() -> Unit = { install(Resources) install(ContentNegotiation) { json(json) } install(ContentEncoding) { deflate(1.0F) gzip(0.9F) } install(HttpRequestRetry) { maxRetries = retry.attempts retryOnException(retryOnTimeout = true) retryOnServerErrors() exponentialDelay(maxDelayMs = retry.maxDelay.inWholeMilliseconds) // modifyRequest { it.headers.append("X_RETRY_COUNT", retryCount.toString()) } } install(HttpTimeout) { connectTimeoutMillis = timeout.connection.inWholeMilliseconds requestTimeoutMillis = timeout.read.inWholeMilliseconds socketTimeoutMillis = timeout.write.inWholeMilliseconds } install(HttpCookies) install(Logging) { level = when { httpLogger.isDebugEnabled() -> LogLevel.ALL httpLogger.isLoggingOff() -> LogLevel.NONE else -> LogLevel.INFO } logger = object : Logger { override fun log(message: String) { httpLogger.info { message } } } format = LoggingFormat.OkHttp sanitizeHeader { header -> header == HttpHeaders.Authorization } // filter { it.url.host.contains("localhost").not() } } engine { pipelining = true // proxy = ProxyBuilder.http() } followRedirects = true install(UserAgent) { agent = "$name-${BuildConfig.version}" } install(DefaultRequest) { headers.appendIfNameAndValueAbsent( HttpHeaders.ContentType, ContentType.Application.Json.toString()) } install(SSE) { maxReconnectionAttempts = retry.attempts reconnectionTime = timeout.connection } install(WebSockets) { pingInterval = timeout.read } expectSuccess = true HttpResponseValidator { handleResponseExceptionWithRequest { ex, req -> val resException = ex as? ResponseException ?: return@handleResponseExceptionWithRequest val res = resException.response httpLogger.trace { "Request failed: ${req.method.value} ${req.url} -> ${res.status}" } } } }): HttpClient

Multiplatform HTTP client engine configuration

actual fun httpClient(name: String, timeout: Timeout, retry: Retry, httpLogger: KLogger, config: HttpClientConfig<*>.() -> Unit): HttpClient
actual fun httpClient(name: String, timeout: Timeout, retry: Retry, httpLogger: KLogger, config: HttpClientConfig<*>.() -> Unit): HttpClient
actual fun httpClient(name: String, timeout: Timeout, retry: Retry, httpLogger: KLogger, config: HttpClientConfig<*>.() -> Unit): HttpClient