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

Function NewClientFromConfig

config/http_config.go:606–618  ·  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

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

Calls 2

newClientFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…