Skip to content

Allow custom http.Transport or http.Client #36

@odannyc

Description

@odannyc

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions