From 2dbbf128d35ac70c477326ed6bef97d54146a44a Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 31 Jul 2018 10:15:02 -0700 Subject: [PATCH] Add ability to pass in WebSocket dialer --- clientbase/common.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clientbase/common.go b/clientbase/common.go index bad9467e0..2a1331fc1 100644 --- a/clientbase/common.go +++ b/clientbase/common.go @@ -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)) }