diff --git a/web/server.go b/web/server.go index 358fdcf..2eef970 100644 --- a/web/server.go +++ b/web/server.go @@ -442,22 +442,20 @@ func (s *Server) handleEvents() http.HandlerFunc { }() // Keep connection open and send events as they arrive - go func() { - for { - select { - case msg, ok := <-clientChan: - if !ok { - return - } - fmt.Fprintf(w, "%s\n\n", msg) - if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() - } - case <-r.Context().Done(): + for { + select { + case msg, ok := <-clientChan: + if !ok { return } + fmt.Fprintf(w, "%s\n\n", msg) + if flusher, ok := w.(http.Flusher); ok { + flusher.Flush() + } + case <-r.Context().Done(): + return } - }() + } } } @@ -505,22 +503,20 @@ func (s *Server) handleAdminEvents() http.HandlerFunc { }() // Keep connection open and send events as they arrive - go func() { - for { - select { - case msg, ok := <-clientChan: - if !ok { - return - } - fmt.Fprintf(w, "%s\n\n", msg) - if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() - } - case <-r.Context().Done(): + for { + select { + case msg, ok := <-clientChan: + if !ok { return } + fmt.Fprintf(w, "%s\n\n", msg) + if flusher, ok := w.(http.Flusher); ok { + flusher.Flush() + } + case <-r.Context().Done(): + return } - }() + } } }