diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 97a2b11..57a9b23 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -7,10 +7,8 @@ import ( "dwelling-radio/pkg/utils" "embed" "encoding/json" - "fmt" "html/template" "io/fs" - "io/ioutil" "net/http" "time" @@ -56,18 +54,7 @@ func (h *RadioHandlers) AssetsFS() http.FileSystem { } func (h *RadioHandlers) Robots(w http.ResponseWriter, r *http.Request) { - f, err := h.AssetsFS().Open("robots.txt") - if err != nil { - w.WriteHeader(http.StatusNotFound) - return - } - defer f.Close() - - fc, err := ioutil.ReadAll(f) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - } - + fc, _ := assetsDir.ReadFile("web/assets/robots.txt") w.Write(fc) } @@ -150,11 +137,8 @@ func (h *RadioHandlers) LastSong(w http.ResponseWriter, r *http.Request) { func (h *RadioHandlers) Playlist(w http.ResponseWriter, _ *http.Request) { w.Header().Add("Content-Disposition", "attachment; filename=\"radio.arav.top.m3u\"") - - pf, _ := assetsDir.Open("radio.arav.top.m3u") - defer pf.Close() - - fmt.Fprint(w, pf) + fc, _ := assetsDir.ReadFile("web/assets/radio.arav.top.m3u") + w.Write(fc) } func compileTemplates(lErr *logging.Logger) {