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

Method Proxy

config/http_config.go:1715–1748  ·  view source on GitHub ↗

Proxy returns the Proxy URL for a request.

()

Source from the content-addressed store, hash-verified

1713
1714// Proxy returns the Proxy URL for a request.
1715func (c *ProxyConfig) Proxy() (fn func(*http.Request) (*url.URL, error)) {
1716 if c == nil {
1717 return nil
1718 }
1719 defer func() {
1720 fn = c.proxyFunc
1721 }()
1722 if c.proxyFunc != nil {
1723 return fn
1724 }
1725 if c.ProxyFromEnvironment {
1726 proxyFn := httpproxy.FromEnvironment().ProxyFunc()
1727 c.proxyFunc = func(req *http.Request) (*url.URL, error) {
1728 return proxyFn(req.URL)
1729 }
1730 return fn
1731 }
1732 if c.ProxyURL.URL != nil && c.ProxyURL.String() != "" {
1733 if c.NoProxy == "" {
1734 c.proxyFunc = http.ProxyURL(c.ProxyURL.URL)
1735 return fn
1736 }
1737 proxy := &httpproxy.Config{
1738 HTTPProxy: c.ProxyURL.String(),
1739 HTTPSProxy: c.ProxyURL.String(),
1740 NoProxy: c.NoProxy,
1741 }
1742 proxyFn := proxy.ProxyFunc()
1743 c.proxyFunc = func(req *http.Request) (*url.URL, error) {
1744 return proxyFn(req.URL)
1745 }
1746 }
1747 return fn
1748}
1749
1750// ProxyConnectHeader() return the Proxy Connext Headers.
1751func (c *ProxyConfig) GetProxyConnectHeader() http.Header {

Callers 3

TestProxyConfig_ProxyFunction · 0.95
newOauth2TokenSourceMethod · 0.80

Calls 1

StringMethod · 0.65

Tested by 1

TestProxyConfig_ProxyFunction · 0.76