1
0

Added robots.txt file and its handler.

This commit is contained in:
Alexander Andreev 2023-05-13 16:00:38 +04:00
parent 5f419d7dd8
commit 8925f2ce24
Signed by: Arav
GPG Key ID: D22A817D95815393
3 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,7 @@ func main() {
srv := http.NewHttpServer() srv := http.NewHttpServer()
srv.SetNotFoundHandler(hand.NotFound) srv.SetNotFoundHandler(hand.NotFound)
srv.GET("/robots.txt", hand.RobotsTxt)
srv.ServeStatic("/assets/*filepath", hand.AssetsFS()) srv.ServeStatic("/assets/*filepath", hand.AssetsFS())
srv.GET("/", hand.Index) srv.GET("/", hand.Index)
srv.POST("/", hand.Upload) srv.POST("/", hand.Upload)

View File

@ -220,3 +220,8 @@ func (h *UploadHandlers) NotFound(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "deleted") fmt.Fprintln(w, "deleted")
} }
} }
func (h *UploadHandlers) RobotsTxt(w http.ResponseWriter, r *http.Request) {
data, _ := web.AssetsGetFile("robots.txt")
w.Write(data)
}

2
web/assets/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow: /assets/