Added a MostListenedSong() handler.
This commit is contained in:
parent
8322d2a7a8
commit
f709ac4b02
@ -110,5 +110,17 @@ func (dj *DJHandlers) Status(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "status parsing failed", http.StatusInternalServerError)
|
http.Error(w, "status parsing failed", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dj *DJHandlers) MostListenedSong(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
mls := radio.MostListened()
|
||||||
|
if mls == nil {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := json.NewEncoder(w).Encode(mls)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("DJHandlers.MostListenedSong:", err)
|
||||||
|
http.Error(w, "MostListenedSong parsing failed", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user