Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom http.Transport or http.Client #36

Open
odannyc opened this issue Nov 17, 2021 · 3 comments
Open

Allow custom http.Transport or http.Client #36

odannyc opened this issue Nov 17, 2021 · 3 comments

Comments

@odannyc
Copy link

odannyc commented Nov 17, 2021

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
}
@philcluff
Copy link
Contributor

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.

@rgalus
Copy link

rgalus commented Feb 15, 2024

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.

@philcluff
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants