GoBlog/robotstxt.go

17 lines
343 B
Go

package main
import (
"fmt"
"net/http"
)
const robotsTXTPath = "/robots.txt"
func (a *goBlog) serveRobotsTXT(w http.ResponseWriter, r *http.Request) {
if a.isPrivate() {
_, _ = w.Write([]byte("User-agent: *\nDisallow: /"))
return
}
_, _ = w.Write([]byte(fmt.Sprintf("User-agent: *\nSitemap: %v", a.getFullAddress(sitemapPath))))
}