subscribeHandler accepts the WebSocket connection and then subscribes it to all future messages.
(w http.ResponseWriter, r *http.Request)
| 70 | // subscribeHandler accepts the WebSocket connection and then subscribes |
| 71 | // it to all future messages. |
| 72 | func (cs *chatServer) subscribeHandler(w http.ResponseWriter, r *http.Request) { |
| 73 | err := cs.subscribe(w, r) |
| 74 | if errors.Is(err, context.Canceled) { |
| 75 | return |
| 76 | } |
| 77 | if websocket.CloseStatus(err) == websocket.StatusNormalClosure || |
| 78 | websocket.CloseStatus(err) == websocket.StatusGoingAway { |
| 79 | return |
| 80 | } |
| 81 | if err != nil { |
| 82 | cs.logf("%v", err) |
| 83 | return |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // publishHandler reads the request body with a limit of 8192 bytes and then publishes |
| 88 | // the received message. |
nothing calls this directly
no test coverage detected