From 6c9e3c69ff9d3c033883e262d55c7a92891f6640 Mon Sep 17 00:00:00 2001 From: Alexey McSakoff Date: Sat, 10 Mar 2018 19:31:40 +0400 Subject: [PATCH] Handle non-WS connections in WS handler with no panic Former-commit-id: f56665ee444bd16258edf6a34606efc132eced5a --- websocket/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket/server.go b/websocket/server.go index a08b3e1a..44120b90 100644 --- a/websocket/server.go +++ b/websocket/server.go @@ -147,6 +147,9 @@ func New(cfg Config) *Server { func (s *Server) Handler() context.Handler { return func(ctx context.Context) { c := s.Upgrade(ctx) + if c.Err() != nil { + return + } // NOTE TO ME: fire these first BEFORE startReader and startPinger // in order to set the events and any messages to send // the startPinger will send the OK to the client and only