diff --git a/cmd/dwelling-upload/main.go b/cmd/dwelling-upload/main.go index 53ab00b..2556133 100644 --- a/cmd/dwelling-upload/main.go +++ b/cmd/dwelling-upload/main.go @@ -84,6 +84,7 @@ func main() { srv := http.NewHttpServer() srv.SetNotFoundHandler(hand.NotFound) + srv.GET("/robots.txt", hand.RobotsTxt) srv.ServeStatic("/assets/*filepath", hand.AssetsFS()) srv.GET("/", hand.Index) srv.POST("/", hand.Upload) diff --git a/internal/http/handlers.go b/internal/http/handlers.go index f3d37f9..eca9acb 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -220,3 +220,8 @@ func (h *UploadHandlers) NotFound(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "deleted") } } + +func (h *UploadHandlers) RobotsTxt(w http.ResponseWriter, r *http.Request) { + data, _ := web.AssetsGetFile("robots.txt") + w.Write(data) +} diff --git a/web/assets/robots.txt b/web/assets/robots.txt new file mode 100644 index 0000000..8811370 --- /dev/null +++ b/web/assets/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /assets/ \ No newline at end of file