From 4b001f576657a9113d1e78a3df323b69e99b64f4 Mon Sep 17 00:00:00 2001 From: yuli Date: Fri, 13 Sep 2024 18:47:47 +0300 Subject: [PATCH] add robots.txt file --- src/bunker.go | 12 ++++++++++++ ui/robots.txt | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 ui/robots.txt diff --git a/src/bunker.go b/src/bunker.go index 1e3b52c..4af6d8f 100644 --- a/src/bunker.go +++ b/src/bunker.go @@ -264,6 +264,18 @@ func (e mainEnv) setupRouter() *httprouter.Router { } } }) + router.GET("/robots.txt", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + data, err := box.Find("robots.txt") + if err != nil { + //log.Panic("error %s", err.Error()) + log.Printf("error: %s\n", err.Error()) + w.WriteHeader(404) + } else { + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(200) + w.Write(data) + } + }) router.GET("/site/*filepath", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { fname := r.URL.Path if fname == "/site/" { diff --git a/ui/robots.txt b/ui/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/ui/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /