Created
July 7, 2025 06:12
-
-
Save codingwitharul/dc9565f66376f20d77ec83401c4f824d to your computer and use it in GitHub Desktop.
androidMain/common/HttpClient.android.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.codingwitharul.bookmyslot.common | |
| import io.ktor.client.HttpClient | |
| import io.ktor.client.HttpClientConfig | |
| import io.ktor.client.engine.okhttp.OkHttp | |
| import io.ktor.client.plugins.HttpTimeout | |
| import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | |
| import io.ktor.client.plugins.defaultRequest | |
| import io.ktor.client.request.header | |
| import io.ktor.serialization.kotlinx.json.json | |
| import kotlinx.serialization.ExperimentalSerializationApi | |
| import kotlinx.serialization.json.Json | |
| import java.util.concurrent.TimeUnit | |
| actual fun httpClient(config: HttpClientConfig<*>.() -> Unit) = HttpClient(OkHttp) { | |
| config(this) | |
| engine { | |
| config { | |
| retryOnConnectionFailure(false) | |
| connectTimeout(30, TimeUnit.SECONDS) | |
| } | |
| } | |
| // platform oriented config goes here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment