diff --git a/auth.go b/auth.go index 0226976..52e9ad5 100644 --- a/auth.go +++ b/auth.go @@ -49,7 +49,7 @@ func authenticate(w http.ResponseWriter, c *websocket.Conn) (*Session, error) { }) if err != nil || !token.Valid { - c.WriteMessage(mt, []byte(`{"status": "unauthorized"}`)) + _ = c.WriteMessage(mt, []byte(`{"status": "unauthorized"}`)) return nil, unauthorized(w) } diff --git a/handler.go b/handler.go index 24b0898..e33aee0 100644 --- a/handler.go +++ b/handler.go @@ -21,13 +21,14 @@ func handler(w http.ResponseWriter, r *http.Request) { upgradefail(w) return } - defer c.Close() var authorized bool var ch chan *broadcast.Event var sub *broadcast.Subscriber defer func() { + _ = c.Close() + if ch != nil && sub != nil { sub.Disconnect(ch) } @@ -54,7 +55,7 @@ func handler(w http.ResponseWriter, r *http.Request) { err := c.WriteMessage(websocket.TextMessage, msg.Data) if err != nil { - internalerror(w) + _ = internalerror(w) return } }