graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

proposal: Use HTTPClient interface instead of *http.Client instance

Open ipfans opened this issue 3 years ago • 4 comments

We can use HTTPClient interface instead of *http.Client instance. For example, we have a custom httpclient that includes features such as our built-in security authentication certificate, retries, and circuit breaker. However, since this library uses *http.Client, this prevents us using these features. It is also very complicated to wrap the corresponding functionality. Currently, there is no use to more internals, interfaces is a very good solution.

type HTTPClient interface{
    Do(*http.Request)(*http.Response, error)
}

ipfans avatar Mar 23 '22 07:03 ipfans

Makes sense. Are you open to submit a PR?

jensneuse avatar Mar 23 '22 07:03 jensneuse

@jensneuse Okay, I will submit a PR later

ipfans avatar Mar 23 '22 07:03 ipfans

@jensneuse I'm afraid we can not do it due to https://github.com/nhooyr/websocket/issues/249

ipfans avatar Mar 28 '22 09:03 ipfans

I see, maybe you have to somehow wrap a custom http client into a transport.

jensneuse avatar Apr 03 '22 10:04 jensneuse

Sure, use a custom transport instead.

ipfans avatar Sep 29 '22 14:09 ipfans