Closed brewin closed 4 years ago
Hi @brewin,
We initially assumed HttpRequestBuilder.takeFrom
as an internal method. Starting from 1.3.1
started to copy executionContext
of the initial request builder and so that became a bit more "dangerous" so we marked it as deprecated.
Could you describe your use case for me to understand how we can bypass the problem?
I may have been using it incorrectly then. My use case is like this:
class SomeDataSource(private val httpClient: HttpClient) {
private val requestBuilder = HttpRequestBuilder().apply {
url {
protocol = URLProtocol.HTTPS
host = "example.com"
}
parameter("param_shared_by_all_requests", 42)
}
suspend fun getSomething(): Something = httpClient.get {
takeFrom(requestBuilder)
parameter("foo", "bar")
}
suspend fun getSomethingElse(): SomethingElse = httpClient.get {
takeFrom(requestBuilder)
parameter("baz", true)
}
}
Added back in 1.3.2. Thanks.
With HttpRequestBuilder.takeFrom(HttpRequestBuilder) deprecated in 1.3.1, what's the recommended way to reuse common request data?