Closed ilius closed 6 years ago
Whats the advantage of this over using the current NewHttpModule
with a http.Client
where you set Client.Transport
to your own RoundTripper
?
This approach is simpler and more flexible. For example we may want to have different timeouts based on the host/domain (from URL). Timeout is part of Client, not Transport.
Ok agreed. Maybe it would even be better to remove NewHttpModule(client)
as it's the same as NewHttpModuleWithDo(client.Do)
but that would break backwards compatibility.
Normally I would ask for separate pull requests for the separate commits as they address different issues but since this a small project I'll allow it :)
We needed to switch between multiple http clients based on the URL/Domain.
So I added
NewHttpModuleWithDo
, that gets theclient.Do
function instead of http client. And it will be used later if it's non-nil