UnmarshalYAML implements the yaml.Unmarshaler interface.
()
| 1696 | |
| 1697 | // UnmarshalYAML implements the yaml.Unmarshaler interface. |
| 1698 | func (c *ProxyConfig) Validate() error { |
| 1699 | if len(c.ProxyConnectHeader) > 0 && (!c.ProxyFromEnvironment && (c.ProxyURL.URL == nil || c.ProxyURL.String() == "")) { |
| 1700 | return errors.New("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured") |
| 1701 | } |
| 1702 | if c.ProxyFromEnvironment && c.ProxyURL.URL != nil && c.ProxyURL.String() != "" { |
| 1703 | return errors.New("if proxy_from_environment is configured, proxy_url must not be configured") |
| 1704 | } |
| 1705 | if c.ProxyFromEnvironment && c.NoProxy != "" { |
| 1706 | return errors.New("if proxy_from_environment is configured, no_proxy must not be configured") |
| 1707 | } |
| 1708 | if c.ProxyURL.URL == nil && c.NoProxy != "" { |
| 1709 | return errors.New("if no_proxy is configured, proxy_url must also be configured") |
| 1710 | } |
| 1711 | return nil |
| 1712 | } |
| 1713 | |
| 1714 | // Proxy returns the Proxy URL for a request. |
| 1715 | func (c *ProxyConfig) Proxy() (fn func(*http.Request) (*url.URL, error)) { |