Open jlordiales opened 5 years ago
Just FYI, You can pass in a Transport to go HTTP client to do exactly the same. Like in this repo: https://github.com/sunfmin/handlertransport, I make the HTTP client doesn't request a remote address but go through a local HTTP handler.
client := &http.Client{
Transport: handlertransport.New(http.HandlerFunc(hf)),
}
@sunfmin yeah, RoundTripper
is nice for simple use cases but it has some important limitations/expectations for a general http client middleware:
Taking a Doer
interface instead of a *http.Client
would still allow you to use the std lib client with a custom transport though.
It would be nice if https://github.com/machinebox/graphql/blob/master/graphql.go#L48 could take a
Doer
interface, compatible with the std lib*http.Client
so that clients can pass in whatever http client they want:This shouldn't break any clients using the std lib today.
I'd be happy to create a PR if you don't see any issue with the change.