Added playlist handler.
This commit is contained in:
parent
3d2b172deb
commit
88b5f21343
@ -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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user