diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index 2453dd9..a5d4be8 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -94,18 +94,21 @@ func (dj *DJHandlers) Songs(w http.ResponseWriter, r *http.Request) { } func (dj *DJHandlers) Status(w http.ResponseWriter, r *http.Request) { - withList := r.URL.Query().Has("with-list") - if withList { - err := json.NewEncoder(w).Encode(&struct { - Current *radio.Song_ `json:"current_song,omitempty"` - Listeners *radio.ListenerCounter `json:"listeners"` - List []radio.Song_ `json:"last_songs,omitempty"` - }{ - Current: songList.Current(), - Listeners: dj.listeners, - List: songList.List()}) - if err != nil { - log.Println("DJHandlers.Status-withList:", err) - } + w.Header().Add("Content-Type", "application/json") + err := json.NewEncoder(w).Encode(&struct { + Current *radio.Song_ `json:"current_song,omitempty"` + Listeners *radio.ListenerCounter `json:"listeners"` + List []radio.Song_ `json:"last_songs,omitempty"` + Mls *radio.MostListenedSong `json:"most_listened_song,omitempty"` + }{ + Current: songList.Current(), + Listeners: dj.listeners, + List: songList.List(), + Mls: radio.MostListened()}) + if err != nil { + log.Println("DJHandlers.Status:", err) + http.Error(w, "status parsing failed", http.StatusInternalServerError) + } +} } }