main
DustyP 9 months ago
parent 3b19054ead
commit c80fc08536

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

Loading…
Cancel
Save