UnmarshalYAML implements the yaml.Unmarshaler interface.
()
| 1212 | |
| 1213 | // UnmarshalYAML implements the yaml.Unmarshaler interface. |
| 1214 | func (c *ProxyConfig) Validate() error { |
| 1215 | if len(c.ProxyConnectHeader) > 0 && (!c.ProxyFromEnvironment && (c.ProxyURL.URL == nil || c.ProxyURL.String() == "")) { |
| 1216 | return fmt.Errorf("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured") |
| 1217 | } |
| 1218 | if c.ProxyFromEnvironment && c.ProxyURL.URL != nil && c.ProxyURL.String() != "" { |
| 1219 | return fmt.Errorf("if proxy_from_environment is configured, proxy_url must not be configured") |
| 1220 | } |
| 1221 | if c.ProxyFromEnvironment && c.NoProxy != "" { |
| 1222 | return fmt.Errorf("if proxy_from_environment is configured, no_proxy must not be configured") |
| 1223 | } |
| 1224 | if c.ProxyURL.URL == nil && c.NoProxy != "" { |
| 1225 | return fmt.Errorf("if no_proxy is configured, proxy_url must also be configured") |
| 1226 | } |
| 1227 | return nil |
| 1228 | } |
| 1229 | |
| 1230 | // Proxy returns the Proxy URL for a request. |
| 1231 | func (c *ProxyConfig) Proxy() (fn func(*http.Request) (*url.URL, error)) { |