git.iko.soy/typeable/oauth2-proxy
on master help sign in
Use pagewriter to render robots txt page
commitf3bd61b37100cf62774642d19a8c87932f2ca2f4 authorJoel Speed <joel.speed@hotmail.co.uk> dateSat 13 Mar 2021, 09:55 (6 years ago) parent9782fc7
2 files changed+2−8
oauthproxy.go+1−7 oauthproxy_test.go+1−1
oauthproxy.go+1−7
@@ -577,13 +577,7 @@ func (p *OAuthProxy) serveHTTP(rw http.ResponseWriter, req *http.Request) {
577577
578578// RobotsTxt disallows scraping pages from the OAuthProxy
579579func (p *OAuthProxy) RobotsTxt(rw http.ResponseWriter, req *http.Request) {
580− _, err := fmt.Fprintf(rw, "User-agent: *\nDisallow: /")
581− if err != nil {
582− logger.Printf("Error writing robots.txt: %v", err)
583− p.ErrorPage(rw, req, http.StatusInternalServerError, err.Error())
584− return
585− }
586− rw.WriteHeader(http.StatusOK)
580+ p.pageWriter.WriteRobotsTxt(rw, req)
587581}
588582
589583// ErrorPage writes an error response
oauthproxy_test.go+1−1
@@ -57,7 +57,7 @@ func TestRobotsTxt(t *testing.T) {
5757 req, _ := http.NewRequest("GET", "/robots.txt", nil)
5858 proxy.ServeHTTP(rw, req)
5959 assert.Equal(t, 200, rw.Code)
60− assert.Equal(t, "User-agent: *\nDisallow: /", rw.Body.String())
60+ assert.Equal(t, "User-agent: *\nDisallow: /\n", rw.Body.String())
6161}
6262
6363func TestIsValidRedirect(t *testing.T) {