Forgot about ReadFile() method of embed.FS.
This commit is contained in:
parent
981bbd8968
commit
93f50458ec
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user