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)
| 602 | // given config.HTTPClientConfig and config.HTTPClientOption. |
| 603 | // The name is used as go-conntrack metric label. |
| 604 | func 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. |