Merge pull request #402 from aquiladev/swarm-network-rewrite

swarm: adds handling GET robots.txt #154 (our default is to disallow crawling, but this can be overwritten using nginx config)
This commit is contained in:
Aron 2018-04-19 14:33:00 +02:00 committed by GitHub
commit 068ad8e71f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -850,6 +850,12 @@ func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return
}
if r.URL.Path == "/robots.txt" {
w.Header().Set("Last-Modified", time.Now().Format(http.TimeFormat))
fmt.Fprintf(w, "User-agent: *\nDisallow: /")
return
}
uri, err := api.Parse(strings.TrimLeft(r.URL.Path, "/"))
if err != nil {
Respond(w, req, fmt.Sprintf("invalid URI %q", r.URL.Path), http.StatusBadRequest)