1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-16 07:09:44 +00:00

Add ability to pass in WebSocket dialer

This commit is contained in:
Darren Shepherd
2018-07-31 10:15:02 -07:00
parent 19878010e4
commit 093318714b

View File

@@ -54,6 +54,7 @@ type ClientOpts struct {
TokenKey string
Timeout time.Duration
HTTPClient *http.Client
WSDialer *websocket.Dialer
CACerts string
Insecure bool
}
@@ -275,6 +276,10 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
Types: result.Types,
}
if result.Opts.WSDialer != nil {
result.Ops.Dialer = result.Opts.WSDialer
}
ht, ok := client.Transport.(*http.Transport)
if ok {
result.Ops.Dialer.TLSClientConfig = ht.TLSClientConfig
@@ -299,6 +304,10 @@ func (a *APIBaseClient) Websocket(url string, headers map[string][]string) (*web
httpHeaders.Add("Authorization", a.Opts.getAuthHeader())
}
if Debug {
fmt.Println("WS " + url)
}
return a.Ops.Dialer.Dial(url, http.Header(httpHeaders))
}