Since ListenersUpdate works with Icecast specifically, let's point it out in its name.
This commit is contained in:
parent
a728ea2164
commit
8d3ec1a327
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user