Add transport field to EndpointConfig struct
The EndpointConfig struct in the notifications package has some config fields for a notification endpoint. This commit adds the ability to pass in an *http.Transport to use when notifying that endpoint of an event. This is especially useful for endpoints that use self-signed CAs. Signed-off-by: Josh Chorlton <josh.chorlton@docker.com>
This commit is contained in:
parent
4e17ab5d31
commit
a62f212544
3 changed files with 42 additions and 6 deletions
|
@ -26,13 +26,16 @@ type httpSink struct {
|
|||
|
||||
// newHTTPSink returns an unreliable, single-flight http sink. Wrap in other
|
||||
// sinks for increased reliability.
|
||||
func newHTTPSink(u string, timeout time.Duration, headers http.Header, listeners ...httpStatusListener) *httpSink {
|
||||
func newHTTPSink(u string, timeout time.Duration, headers http.Header, transport *http.Transport, listeners ...httpStatusListener) *httpSink {
|
||||
if transport == nil {
|
||||
transport = http.DefaultTransport.(*http.Transport)
|
||||
}
|
||||
return &httpSink{
|
||||
url: u,
|
||||
listeners: listeners,
|
||||
client: &http.Client{
|
||||
Transport: &headerRoundTripper{
|
||||
Transport: http.DefaultTransport.(*http.Transport),
|
||||
Transport: transport,
|
||||
headers: headers,
|
||||
},
|
||||
Timeout: timeout,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue