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

Method Proxy

config/http_config.go:1711–1744  ·  view source on GitHub ↗

Proxy returns the Proxy URL for a request.

()

Source from the content-addressed store, hash-verified

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