MCPcopy Create free account
hub / github.com/prometheus/common / NewClientFromConfig

Function NewClientFromConfig

config/http_config.go:604–616  ·  view source on GitHub ↗

NewClientFromConfig returns a new HTTP client configured for the given config.HTTPClientConfig and config.HTTPClientOption. The name is used as go-conntrack metric label.

(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption)

Source from the content-addressed store, hash-verified

602// given config.HTTPClientConfig and config.HTTPClientOption.
603// The name is used as go-conntrack metric label.
604func NewClientFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption) (*http.Client, error) {
605 rt, err := NewRoundTripperFromConfig(cfg, name, optFuncs...)
606 if err != nil {
607 return nil, err
608 }
609 client := newClient(rt)
610 if !cfg.FollowRedirects {
611 client.CheckRedirect = func(*http.Request, []*http.Request) error {
612 return http.ErrUseLastResponse
613 }
614 }
615 return client, nil
616}
617
618// NewRoundTripperFromConfig returns a new HTTP RoundTripper configured for the
619// given config.HTTPClientConfig and config.HTTPClientOption.

Calls 2

newClientFunction · 0.85