forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proxy support for http input (influxdata#8477)
- Loading branch information
Showing
3 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package proxy | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
type HTTPProxy struct { | ||
HTTPProxyURL string `toml:"http_proxy_url"` | ||
} | ||
|
||
type proxyFunc func(req *http.Request) (*url.URL, error) | ||
|
||
func (p *HTTPProxy) Proxy() (proxyFunc, error) { | ||
if len(p.HTTPProxyURL) > 0 { | ||
url, err := url.Parse(p.HTTPProxyURL) | ||
if err != nil { | ||
return nil, fmt.Errorf("error parsing proxy url %q: %w", p.HTTPProxyURL, err) | ||
} | ||
return http.ProxyURL(url), nil | ||
} | ||
return http.ProxyFromEnvironment, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters