1
0

Template was replaced with a pre-compiled to a Go source file.

This commit is contained in:
Alexander Andreev 2022-06-13 18:35:36 +04:00
parent 89429d7fd2
commit b5d8b58b81
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -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) {