diff --git a/cmd/dwelling-radio/main.go b/cmd/dwelling-radio/main.go index d34b58b..7b069e7 100644 --- a/cmd/dwelling-radio/main.go +++ b/cmd/dwelling-radio/main.go @@ -51,6 +51,7 @@ func main() { srv.GET("/lastsong", hand.LastSong) srv.GET("/playlist", hand.Playlist) srv.GET("/filelist", hand.Filelist) + srv.GET("/robots.txt", hand.RobotsTxt) if !*noLiquidsoap { liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath) diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 97865d8..ce5e512 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -104,3 +104,8 @@ func (h *Handlers) Filelist(w http.ResponseWriter, _ *http.Request) { data, _ := os.ReadFile(h.conf.FilelistPath) w.Write(data) } + +func (h *Handlers) RobotsTxt(w http.ResponseWriter, _ *http.Request) { + w.Header().Add("Content-Disposition", "attachment; filename=\"robots.txt\"") + w.Write([]byte("User-agent: *\nDisallow: /assets/\nDisallow: /live/")) +}