Added a robots.txt file and a handler for it.
This commit is contained in:
parent
2b18204a6c
commit
ee96af31ad
@ -57,6 +57,7 @@ func main() {
|
||||
|
||||
srv.ServeStatic("/assets/*filepath", hand.AssetsFS())
|
||||
srv.GET("/", hand.Index)
|
||||
srv.GET("/robots.txt", hand.Robots)
|
||||
srv.GET("/stats", hand.Stats)
|
||||
srv.GET("/lastsong", hand.LastSong)
|
||||
srv.GET("/playlist", hand.Playlist)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -54,6 +55,22 @@ func (h *RadioHandlers) AssetsFS() http.FileSystem {
|
||||
return http.FS(f)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
w.Write(fc)
|
||||
}
|
||||
|
||||
func (h *RadioHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := radio.IcecastGetStatus(h.conf.Icecast.URL)
|
||||
if err != nil {
|
||||
|
3
internal/handlers/web/assets/robots.txt
Normal file
3
internal/handlers/web/assets/robots.txt
Normal file
@ -0,0 +1,3 @@
|
||||
User-agent: *
|
||||
Disallow: /assets/
|
||||
Disallow: /live/
|
Loading…
Reference in New Issue
Block a user