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
I'm proposing a similar addition, satisfying the http.RoundTripper interface. This would enable composable RoundTrippers and avoid the need to create a struct in some instances.
funcaddAuthRoundTripper(apiKeystring) http.RoundTripper {
returnhttp.RoundTripperFunc(func(r*http.Request) (*http.Response, error) {
r.SetBasicAuth("", apiKey) // Not super secure, just using as an examplereturnhttp.DefaultTransport.RoundTrip(r)
})
}
Without
This shows the required effort without this addition.
The http package currently exposes a
HandlerFunc
interface that satisfies thehttp.Handler
interface.I'm proposing a similar addition, satisfying the
http.RoundTripper
interface. This would enable composable RoundTrippers and avoid the need to create a struct in some instances.Proposed design
Example usage
Without
This shows the required effort without this addition.
The text was updated successfully, but these errors were encountered: