1
0

Added robots.txt endpoint.

This commit is contained in:
Alexander Andreev 2023-02-19 21:22:56 +04:00
parent 182a4c02c9
commit aa0d818488
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
2 changed files with 6 additions and 0 deletions

View File

@ -51,6 +51,7 @@ func main() {
srv.GET("/lastsong", hand.LastSong) srv.GET("/lastsong", hand.LastSong)
srv.GET("/playlist", hand.Playlist) srv.GET("/playlist", hand.Playlist)
srv.GET("/filelist", hand.Filelist) srv.GET("/filelist", hand.Filelist)
srv.GET("/robots.txt", hand.RobotsTxt)
if !*noLiquidsoap { if !*noLiquidsoap {
liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath) liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath)

View File

@ -104,3 +104,8 @@ func (h *Handlers) Filelist(w http.ResponseWriter, _ *http.Request) {
data, _ := os.ReadFile(h.conf.FilelistPath) data, _ := os.ReadFile(h.conf.FilelistPath)
w.Write(data) 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/"))
}