Switch to HTTP client interface to allow wrapped clients#86
Switch to HTTP client interface to allow wrapped clients#86nitishm wants to merge 2 commits intooapi-codegen:masterfrom
Conversation
|
@nitishm Just asking: since the generated client here accepts an HTTPClient, the retry mechanisms or any other advanced stuff like oauth2 should already be possible. What would make sense is provide maybe an extension to the Readme how one can create some cool HTTPclients and inject them in the generates client here. But maybe I am misunderstanding something. |
The standard HTTP client is pretty good but there are cases where you might want to wrap it with some extra functionality (think decorator pattern). In my case, I am looking to add some retry options to the HTTP client using different backoff strategies. Unfortunately, the standard HTTP client library does not provide retry capabilities, and due to the generated code using oapi-codegen client, I cannot modify it to include retry capability. @weitzj Hope that makes sense. Let me know if you think there is a better alternative. |
07121de to
cddf7c0
Compare
|
Hey, How does this compare to #85 ? |
|
Seems like this was already done in #85 and can be closed. |
The standard library doesn't support features like Retry of error and different backoff strategies for the same. The recommended approach is to wrap the standard library HTTP client package with any custom handling logic. (See ianlancetaylor's reponse in golang/go#16047)
I propose adding an HTTPClient interface with the same method signatures as the standard library HTTP Client