1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 13:30:26 +00:00

Add robots.txt

This commit is contained in:
bouncepaw 2020-12-29 13:10:11 +05:00
parent 598a87f878
commit 30c95dd037

12
main.go
View File

@ -128,6 +128,17 @@ func handlerIcon(w http.ResponseWriter, rq *http.Request) {
} }
} }
func handlerRobotsTxt(w http.ResponseWriter, rq *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
w.Write([]byte(
`User-agent: *
Allow: /page/
Allow: /recent-changes
Disallow: /
Crawl-delay: 5`))
}
func main() { func main() {
log.Println("Running MycorrhizaWiki β") log.Println("Running MycorrhizaWiki β")
parseCliArgs() parseCliArgs()
@ -157,5 +168,6 @@ func main() {
http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
http.Redirect(w, rq, "/page/"+util.HomePage, http.StatusSeeOther) http.Redirect(w, rq, "/page/"+util.HomePage, http.StatusSeeOther)
}) })
http.HandleFunc("/robots.txt", handlerRobotsTxt)
log.Fatal(http.ListenAndServe("0.0.0.0:"+util.ServerPort, nil)) log.Fatal(http.ListenAndServe("0.0.0.0:"+util.ServerPort, nil))
} }