diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index 10fc228..2912794 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -9,10 +9,11 @@ import ( type DJHandlers struct { listeners *radio.Listeners + playlist *radio.Playlist } -func NewDJHandlers(listeners *radio.Listeners) *DJHandlers { - return &DJHandlers{listeners: listeners} +func NewDJHandlers(l *radio.Listeners, p *radio.Playlist) *DJHandlers { + return &DJHandlers{listeners: l, playlist: p} } 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") 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) +}