1
0

Added playlist handler.

This commit is contained in:
Alexander Andreev 2023-10-01 01:32:57 +04:00
parent 3d2b172deb
commit 88b5f21343
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -9,10 +9,11 @@ import (
type DJHandlers struct { type DJHandlers struct {
listeners *radio.Listeners listeners *radio.Listeners
playlist *radio.Playlist
} }
func NewDJHandlers(listeners *radio.Listeners) *DJHandlers { func NewDJHandlers(l *radio.Listeners, p *radio.Playlist) *DJHandlers {
return &DJHandlers{listeners: listeners} return &DJHandlers{listeners: l, playlist: p}
} }
func (dj *DJHandlers) ListenersGet(w http.ResponseWriter, _ *http.Request) { func (dj *DJHandlers) ListenersGet(w http.ResponseWriter, _ *http.Request) {
@ -37,3 +38,12 @@ func (dj *DJHandlers) ListenersDec(w http.ResponseWriter, _ *http.Request) {
w.Header().Add("Content-Type", "text/plain") w.Header().Add("Content-Type", "text/plain")
fmt.Fprint(w, l) fmt.Fprint(w, l)
} }
func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) {
w.Header().Add("Content-Type", "text/plain")
nxt := dj.playlist.Next()
if nxt == "" {
log.Println("the end of a playlist has been reached")
}
fmt.Fprint(w, nxt)
}