refactor pushing state over websocket into a func
This commit is contained in:
@@ -29,10 +29,10 @@ func (s *S) serveWS(w http.ResponseWriter, r *http.Request) error {
|
|||||||
}
|
}
|
||||||
defer c.CloseNow()
|
defer c.CloseNow()
|
||||||
ws := WS{S: s, c: c}
|
ws := WS{S: s, c: c}
|
||||||
return ws.serve(w, r)
|
return ws.Serve(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws WS) serve(w http.ResponseWriter, r *http.Request) error {
|
func (ws WS) Serve(w http.ResponseWriter, r *http.Request) error {
|
||||||
ctx, can := context.WithCancel(r.Context())
|
ctx, can := context.WithCancel(r.Context())
|
||||||
defer can()
|
defer can()
|
||||||
r = r.WithContext(ctx)
|
r = r.WithContext(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user