diff --git a/templates/default/queue.tmpl b/templates/default/queue.tmpl index 84412def..e899cd8e 100644 --- a/templates/default/queue.tmpl +++ b/templates/default/queue.tmpl @@ -1,3 +1,4 @@ {{define "content"}} -Queue {{printjson .}} +Queue +{{printjson .}} {{end}} \ No newline at end of file diff --git a/website/public/queue.go b/website/public/queue.go index 506c4808..d1a8311a 100644 --- a/website/public/queue.go +++ b/website/public/queue.go @@ -1,20 +1,36 @@ package public import ( - "log" "net/http" + + radio "github.com/R-a-dio/valkyrie" ) -func (s State) GetQueue(w http.ResponseWriter, r *http.Request) { - queueInput := struct { +func (s State) getQueue(w http.ResponseWriter, r *http.Request) error { + input := struct { shared + Queue []radio.QueueEntry }{ shared: s.shared(r), } - err := s.TemplateExecutor.ExecuteFull(theme, "queue", w, queueInput) + queue, err := s.Streamer.Queue(r.Context()) + if err != nil { + return err + } + input.Queue = queue + + err = s.TemplateExecutor.ExecuteFull(theme, "queue", w, input) + if err != nil { + return err + } + return nil +} + +func (s State) GetQueue(w http.ResponseWriter, r *http.Request) { + err := s.getQueue(w, r) if err != nil { - log.Println(err) + s.errorHandler(w, r, err) return } }