main
DustyP 9 months ago
parent 0a888dd446
commit 3b19054ead

@ -442,20 +442,22 @@ func (s *Server) handleEvents() http.HandlerFunc {
}()
// Keep connection open and send events as they arrive
for {
select {
case msg, ok := <-clientChan:
if !ok {
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():
return
}
fmt.Fprintf(w, "%s\n\n", msg)
if flusher, ok := w.(http.Flusher); ok {
flusher.Flush()
}
case <-r.Context().Done():
return
}
}
}()
}
}
@ -503,20 +505,22 @@ func (s *Server) handleAdminEvents() http.HandlerFunc {
}()
// Keep connection open and send events as they arrive
for {
select {
case msg, ok := <-clientChan:
if !ok {
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():
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