refactor pushing state over websocket into a func

main
Bel LaPointe 2024-12-15 11:24:51 -07:00
parent 64165c5745
commit c6da3d17a1
1 changed files with 2 additions and 2 deletions

View File

@ -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)