-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Kotlin][Multiplatform] Support custom Ktor HTTP client configuration #10968
[Kotlin][Multiplatform] Support custom Ktor HTTP client configuration #10968
Conversation
010d999
to
fa1585b
Compare
@@ -25,16 +26,32 @@ import {{packageName}}.auth.* | |||
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient( | |||
private val baseUrl: String, | |||
httpClientEngine: HttpClientEngine?, | |||
httpClientConfig: ((HttpClientConfig<*>) -> Unit)?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkirshboim can you please make this with null value by default and remove the extra constructor?
httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@4brunu ✅ Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let's wait for the CI to finish 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@4brunu CI passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
PR Description
The Problem
It is currently not possible to configure the Ktor HTTP client when using generated Kotlin Multiplatform code.
Configuring the HTTP client can be useful for logging or customising request headers, to name a few use cases.
This issue has been raised in #10130 .
The Solution
This PR makes it possible to configure the Ktor HTTP client by allowing to pass an optional
httpClientConfig
parameter to the generated API classes.An example of how the new
httpClientConfig
parameter can be used can be seen here:Fixes #10130
CCs
Kotlin technical committee: @jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m
Reporter of #10130 : @krzema12
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x