From b5d8b58b819a2ae15ef878576998c3c287c0ac8f Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 13 Jun 2022 18:35:36 +0400 Subject: [PATCH] Template was replaced with a pre-compiled to a Go source file. --- internal/handlers/handlers.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) 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) {