1
0

Since ListenersUpdate works with Icecast specifically, let's point it out in its name.

This commit is contained in:
Alexander Andreev 2024-05-16 01:59:26 +04:00
parent a728ea2164
commit 8d3ec1a327
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
2 changed files with 5 additions and 5 deletions

View File

@ -89,7 +89,7 @@ func main() {
s := r.Sub("/api")
s.Handler(http.MethodPost, "/listener/icecast", djh.ListenersUpdate)
s.Handler(http.MethodPost, "/listener/icecast", djh.ListenersUpdateIcecast)
s.Handler(http.MethodGet, "/playlist", djh.PlaylistNext)
s.Handler(http.MethodGet, "/status", djh.Status)

View File

@ -27,15 +27,15 @@ func NewDJHandlers(l *radio.ListenerCounter, p *radio.Playlist,
stats: stats, curSong: cs, listLen: n, fallbackSong: fS}
}
func (dj *DJHandlers) ListenersUpdate(w http.ResponseWriter, r *http.Request) {
func (dj *DJHandlers) ListenersUpdateIcecast(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
log.Println("DJHandlers.ListenersUpdate panic:", err)
log.Println("DJHandlers.ListenersUpdateIcecast panic:", err)
}
}()
if err := r.ParseForm(); err != nil {
log.Println("DJHandlers.ListenersUpdate:", err)
log.Println("DJHandlers.ListenersUpdateIcecast:", err)
http.Error(w, "cannot parse form", http.StatusBadRequest)
return
}
@ -45,7 +45,7 @@ func (dj *DJHandlers) ListenersUpdate(w http.ResponseWriter, r *http.Request) {
_ = dj.listeners.Inc()
case "listener_remove":
if _, err := dj.listeners.Dec(); err != nil {
log.Println("DJHandlers.ListenersUpdate:", err)
log.Println("DJHandlers.ListenersUpdateIcecast:", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}