Skip to content

Commit

Permalink
Add customization of HTTP client configuration (#10).
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonides committed Nov 11, 2024
1 parent 4697e1e commit b33e1d7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Next release

- Added: customize HTTP client configuration.

## v0.3.6 - 2024-10-15

- BREAKING: Remove `Authentication` from Public API surface. this shouldn't have been used by anyone, it was just used internally, and its usages are refactored now.
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ val client = PodcastIndexClient(...) {
defaultTimeout = 5_000L // 5 seconds
}
```
- Specify optional custom HttpClient configuration (see [HttpClientConfig](https://api.ktor.io/ktor-client/ktor-client-core/io.ktor.client/-http-client-config/index.html)):
```kotlin
val client = PodcastIndexClient(...) {
customHttpClientConfig = {
install(MyCustomPlugin)
engine {
...
}
}
}
```

## Support table
Some endpoints are still work-in-progress and not implemented yet (⌛)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public fun PodcastIndexClient(
if (config.enableTimeout) {
installTimeoutPlugin(config.defaultTimeout)
}
with(config) {
customHttpClientConfig()
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public fun PodcastIndexClient(
if (config.enableTimeout) {
installTimeoutPlugin(config.defaultTimeout)
}
with(config) {
customHttpClientConfig()
}
},
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mr3y.podcastindex

import io.ktor.client.HttpClientConfig

@DslMarker
@InternalPodcastIndexApi
public annotation class PodcastIndexConfigDsl
Expand Down Expand Up @@ -34,4 +36,9 @@ public class PodcastIndexClientConfig {
* The default timeout for requests in milliseconds. Default is 10_000.
*/
public var defaultTimeout: Long = 10_000

/**
* Additional custom configuration block. Default is empty.
*/
public var customHttpClientConfig: HttpClientConfig<*>.() -> Unit = {}
}

0 comments on commit b33e1d7

Please sign in to comment.