Skip to content

Commit

Permalink
extension/websocket: support dial with customized dialer instance
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Dec 31, 2023
1 parent e32daca commit 03c172d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extension/protocol/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,15 @@ func Listen(addr string, upgrader *websocket.Upgrader) (net.Listener, error) {
}

// Dial wraps websocket dial
func Dial(url string) (net.Conn, error) {
c, _, err := websocket.DefaultDialer.Dial(url, nil)
func Dial(url string, args ...interface{}) (net.Conn, error) {
dialer := websocket.DefaultDialer
if len(args) > 0 {
d, ok := args[0].(*websocket.Dialer)
if ok {
dialer = d
}
}
c, _, err := dialer.Dial(url, nil)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 03c172d

Please sign in to comment.