Skip to content

Commit

Permalink
add robots.txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
stremovsky committed Sep 13, 2024
1 parent 52c054a commit 4b001f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bunker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/" {
Expand Down
2 changes: 2 additions & 0 deletions ui/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /

0 comments on commit 4b001f5

Please sign in to comment.