Skip to content

Commit

Permalink
Allow extra HTTP client config
Browse files Browse the repository at this point in the history
  • Loading branch information
Micha-ohne-el committed Oct 24, 2023
1 parent f7d7445 commit 6055066
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commonMain/kotlin/moe/micha/deeplkt/DeeplClient.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.micha.deeplkt

import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.call.body
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
Expand Down Expand Up @@ -41,6 +42,7 @@ class DeeplClient(
} else {
"https://api.deepl.com/v2/"
},
extraHttpClientConfig: HttpClientConfig<*>.() -> Unit = {},
) {
suspend fun translate(
text: String,
Expand Down Expand Up @@ -169,6 +171,8 @@ class DeeplClient(
url(apiUrl)
header("Authorization", "DeepL-Auth-Key $authKey")
}

extraHttpClientConfig()
}

private fun StringValuesBuilder.append(name: String, value: String?) {
Expand Down

0 comments on commit 6055066

Please sign in to comment.