|
|
|
|
@ -462,6 +462,7 @@ func (s *Server) handleEvents() http.HandlerFunc {
|
|
|
|
|
// handleAdminEvents handles SSE events
|
|
|
|
|
func (s *Server) handleAdminEvents() http.HandlerFunc {
|
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
s.logger.Info("Admin events SSE connection established")
|
|
|
|
|
// Set headers for SSE
|
|
|
|
|
w.Header().Set("Content-Type", "text/event-stream")
|
|
|
|
|
w.Header().Set("Cache-Control", "no-cache")
|
|
|
|
|
@ -475,15 +476,17 @@ func (s *Server) handleAdminEvents() http.HandlerFunc {
|
|
|
|
|
http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
s.logger.Info("Admin events SSE headers flushed")
|
|
|
|
|
|
|
|
|
|
// Create a channel for this client
|
|
|
|
|
clientChan := make(chan string, 10)
|
|
|
|
|
|
|
|
|
|
s.logger.Info("Admin events SSE client channel created")
|
|
|
|
|
// Add client to map with mutex protection
|
|
|
|
|
s.adminclientsMux.Lock()
|
|
|
|
|
s.adminclients[clientChan] = true
|
|
|
|
|
clientCount := len(s.adminclients)
|
|
|
|
|
s.adminclientsMux.Unlock()
|
|
|
|
|
s.logger.Info("Admin events SSE client added to map")
|
|
|
|
|
|
|
|
|
|
s.logger.Info("New client connected",
|
|
|
|
|
"clientIP", r.RemoteAddr,
|
|
|
|
|
|