Skip to content

Commit

Permalink
add redirect client config...
Browse files Browse the repository at this point in the history
  • Loading branch information
astinz committed Jan 20, 2024
1 parent 6818d5d commit de2c9ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/commonMain/kotlin/xyz/mcxross/ksui/client/ClientConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data class ConfigContainer(
val agentName: String,
val requestTimeout: Long,
val connectionTimeout: Long,
val followRedirectsWrapper: Boolean,
val enableLogging: Boolean,
val loggerWrapper: xyz.mcxross.ksui.util.Logger,
val logLevelWrapper: xyz.mcxross.ksui.util.LogLevel,
Expand All @@ -28,6 +29,7 @@ data class ConfigContainer(

fun httpClient() =
HttpClient(selectedEngine) {
followRedirects = followRedirectsWrapper
install(UserAgent) { agent = agentName }
install(ContentNegotiation) { json() }
install(HttpRequestRetry) {
Expand Down Expand Up @@ -119,6 +121,13 @@ class ClientConfig {
*/
var logLevel: xyz.mcxross.ksui.util.LogLevel = xyz.mcxross.ksui.util.LogLevel.INFO

/**
* Sets whether to follow redirects.
*
* Defaults to true
*/
var followRedirects: Boolean = true

/**
* Builds a new instance of [SuiHttpClient].
*
Expand All @@ -139,6 +148,7 @@ class ClientConfig {
enableLogging = enableLogging,
loggerWrapper = logger,
logLevelWrapper = logLevel,
followRedirectsWrapper = followRedirects,
)
)
}
Expand All @@ -155,6 +165,7 @@ class ClientConfig {
enableLogging = enableLogging,
loggerWrapper = logger,
logLevelWrapper = logLevel,
followRedirectsWrapper = followRedirects,
)
)
}
Expand Down

0 comments on commit de2c9ba

Please sign in to comment.