diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index edf51cd..7682318 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -13,20 +13,12 @@ import ( const FormatISO8601 = "2006-01-02T15:04:05-0700" -type IndexData struct { - MainSite string - Status *radio.IcecastStatus - Songs []radio.Song -} - type RadioHandlers struct { conf *configuration.Configuration logErr *logging.Logger } func NewRadioHandlers(conf *configuration.Configuration, lErr *logging.Logger) *RadioHandlers { - web.CompileTemplates(lErr) - return &RadioHandlers{ conf: conf, logErr: lErr} @@ -62,14 +54,7 @@ func (h *RadioHandlers) Index(w http.ResponseWriter, r *http.Request) { } } - if err := web.IndexTemplate.Execute(w, &IndexData{ - MainSite: utils.MainSite(r.Host), - Status: status, - Songs: songs, - }); err != nil { - h.logErr.Fatalln("failed to execute Index template:", err) - http.Error(w, "cannot execute Index template", http.StatusInternalServerError) - } + web.Index(utils.MainSite(r.Host), status, &songs, w) } func (h *RadioHandlers) Status(w http.ResponseWriter, r *http.Request) {