mux-go
mux-go copied to clipboard
Allow custom http.Transport or http.Client
I'd like to add tracing to mux http calls but need a way to tap into the http.Client that mux uses under the hood. Typically other libraries expose a way to modify the http.Transport of the http.Client they're using.
I'm thinking maybe exposing this via the ConfigurationOption func:
func WithHTTPRoundTripper(roundTripper http.RoundTripper) ConfigurationOption {
return func(c *Configuration) {
c.httpRoundTripper = roundTripper
}
}
and later on in client.go
if cfg.httpRoundTripper == nil {
cfg.httpRoundTripper = http.DefaultTransport
}
c.httpc = &http.Client{
Timeout: cfg.timeout,
Transport: cfg.httpRoundTripper
}
Hey @odannyc, thanks for the suggestion here, really appreciate it, I agree this would be useful.
I'll add this to the list of possible improvements for the golang SDK.
Thanks again for the feedback.
Hey @philcluff, any update on this?
I have another use case for injecting custom transport into http client and now I need to fork repository to make it work.
Hi @rgalus, Unfortunately this work is not currently planned, while we are working on an updated go SDK, this is not currently in scope.
Thank you.