You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR I'm trying to add some robustness to web service requests, but I find it very difficult to add this without an interface for http.Client.
To sketch the situation:
This factory (google-api-go-client Translate) requires an http.Client as argument.
This library wraps http.Client to provide all sorts of great features for adding robustness.
Because Go doesn't offer an interface type for http.Client, only concrete types can be used and thus there is no (sensible) way to use pester.Client even though it is a drop-in replacement for http.Client.
What I've done so far
I've searched for an interface that can be used by the Translate SDK so that it can be changed to accept a custom concrete type, but I didn't find any.
Adding an interface for http.Client in the http package does not seem right. That suggests that other people will want to implement the interface. Since they will do, it will be impossible for us in practice to add new methods to the http.Client interface, since that would break other packages.
Instead, packages that want to use http.Client, and want to permit wrapping, should define their own interface, and use it.
Closing because I don't think there is anything to do in the Go standard library.
TL;DR I'm trying to add some robustness to web service requests, but I find it very difficult to add this without an interface for
http.Client
.To sketch the situation:
http.Client
as argument.http.Client
to provide all sorts of great features for adding robustness.http.Client
, only concrete types can be used and thus there is no (sensible) way to usepester.Client
even though it is a drop-in replacement forhttp.Client
.What I've done so far
A related thread: googleapis/google-api-go-client#142 (comment)
The text was updated successfully, but these errors were encountered: