From d98a110aef2c066931a479d6d2e795faec1bf6e1 Mon Sep 17 00:00:00 2001 From: Sergii Bomko Date: Thu, 19 Apr 2018 09:36:39 +0200 Subject: [PATCH 1/2] adds handling robot.txt rout #154 --- swarm/api/http/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index 4d93c7362d..6ff5dbfdc9 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -850,6 +850,12 @@ func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request) { return } + if r.URL.Path == "/robot.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) From f0de54eaf10bf19d8af12294bc78e52013dd2332 Mon Sep 17 00:00:00 2001 From: Sergii Bomko Date: Thu, 19 Apr 2018 10:20:07 +0200 Subject: [PATCH 2/2] fixes typo robots #154 --- swarm/api/http/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index 6ff5dbfdc9..c5f97ab775 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -850,7 +850,7 @@ func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request) { return } - if r.URL.Path == "/robot.txt" { + if r.URL.Path == "/robots.txt" { w.Header().Set("Last-Modified", time.Now().Format(http.TimeFormat)) fmt.Fprintf(w, "User-agent: *\nDisallow: /") return