@@ -70,7 +70,7 @@ func (cs *chatServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
70
70
// subscribeHandler accepts the WebSocket connection and then subscribes
71
71
// it to all future messages.
72
72
func (cs * chatServer )subscribeHandler (w http.ResponseWriter ,r * http.Request ) {
73
- err := cs .subscribe (r . Context (), w ,r )
73
+ err := cs .subscribe (w ,r )
74
74
if errors .Is (err ,context .Canceled ) {
75
75
return
76
76
}
@@ -111,7 +111,7 @@ func (cs *chatServer) publishHandler(w http.ResponseWriter, r *http.Request) {
111
111
//
112
112
// It uses CloseRead to keep reading from the connection to process control
113
113
// messages and cancel the context if the connection drops.
114
- func (cs * chatServer )subscribe (ctx context. Context , w http.ResponseWriter ,r * http.Request )error {
114
+ func (cs * chatServer )subscribe (w http.ResponseWriter ,r * http.Request )error {
115
115
var mu sync.Mutex
116
116
var c * websocket.Conn
117
117
var closed bool
@@ -142,7 +142,7 @@ func (cs *chatServer) subscribe(ctx context.Context, w http.ResponseWriter, r *h
142
142
mu .Unlock ()
143
143
defer c .CloseNow ()
144
144
145
- ctx = c .CloseRead (ctx )
145
+ ctx : =c .CloseRead (context . Background () )
146
146
147
147
for {
148
148
select {