Skip to content

Addition of options to allow loading of custom certificates #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/wsjs/wsjs_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func handleJSError(err *error, onErr func()) {
}

// New is a wrapper around the javascript WebSocket constructor.
func New(url string, protocols []string) (c WebSocket, err error) {
func New(url string, protocols []string, options map[string]interface{}) (c WebSocket, err error) {
defer handleJSError(&err, func() {
c = WebSocket{}
})
Expand All @@ -38,7 +38,7 @@ func New(url string, protocols []string) (c WebSocket, err error) {
}

c = WebSocket{
v: js.Global().Get("WebSocket").New(url, jsProtocols),
v: js.Global().Get("WebSocket").New(url, jsProtocols, options),
}

c.setBinaryType("arraybuffer")
Expand Down
3 changes: 2 additions & 1 deletion ws_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func (c *Conn) Subprotocol() string {
type DialOptions struct {
// Subprotocols lists the subprotocols to negotiate with the server.
Subprotocols []string
Options map[string]interface{}
}

// Dial creates a new WebSocket connection to the given url with the given options.
Expand All @@ -259,7 +260,7 @@ func dial(ctx context.Context, url string, opts *DialOptions) (*Conn, *http.Resp
url = strings.Replace(url, "http://", "ws://", 1)
url = strings.Replace(url, "https://", "wss://", 1)

ws, err := wsjs.New(url, opts.Subprotocols)
ws, err := wsjs.New(url, opts.Subprotocols, opts.Options)
if err != nil {
return nil, nil, err
}
Expand Down