Skip to content

Commit

Permalink
Move the Upgrader to the handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Oct 2, 2024
1 parent 026bc94 commit 5cc5604
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions caddy/websocket_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func init() {
// WebSocketHandler implements a Caddy plugin for WebSocket connections.
type WebSocketHandler struct {
logger *slog.Logger
u websocket.Upgrader
}

var (
Expand All @@ -71,8 +72,7 @@ func (h *WebSocketHandler) Handle(cx *layer4.Connection, next layer4.Handler) er

// Upgrade the TCP connection to a WebSocket connection
rw := &responseWriter{cx, req.Header}
upgrader := websocket.Upgrader{}
wsConn, err := upgrader.Upgrade(rw, req, nil)
wsConn, err := h.u.Upgrade(rw, req, nil)
if err != nil {
return fmt.Errorf("error upgrading connection:", err)
}
Expand Down

0 comments on commit 5cc5604

Please sign in to comment.