refactor pushing state over websocket into a func
parent
64165c5745
commit
c6da3d17a1
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue