Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions config/http_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error {
return checkOverflow(a.XXX, "basic_auth")
}

// NewHTTPClientFromConfig returns a new HTTP client configured for the
// given config.HTTPClientConfig.
func NewHTTPClientFromConfig(cfg *HTTPClientConfig) (*http.Client, error) {
// NewHTTPRoundTripperFromConfig returns a new HTTP RoundTripper configured for
// the given config.HTTPClientConfig.
func NewHTTPRoundTripperFromConfig(cfg *HTTPClientConfig) (http.RoundTripper, error) {
tlsConfig, err := NewTLSConfig(&cfg.TLSConfig)
if err != nil {
return nil, err
Expand Down Expand Up @@ -149,6 +149,17 @@ func NewHTTPClientFromConfig(cfg *HTTPClientConfig) (*http.Client, error) {
rt = NewBasicAuthRoundTripper(cfg.BasicAuth.Username, Secret(cfg.BasicAuth.Password), rt)
}

return rt, nil
}

// NewHTTPClientFromConfig returns a new HTTP client configured for the
// given config.HTTPClientConfig.
func NewHTTPClientFromConfig(cfg *HTTPClientConfig) (*http.Client, error) {
rt, err := NewHTTPRoundTripperFromConfig(cfg)
if err != nil {
return nil, err
}

// Return a new client with the configured round tripper.
return &http.Client{Transport: rt}, nil
}
Expand Down