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)
| 604 | // given config.HTTPClientConfig and config.HTTPClientOption. |
| 605 | // The name is used as go-conntrack metric label. |
| 606 | func 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. |
searching dependent graphs…