Open platform to collect and prioritize feedback
enhancement: add sitemap to robots.txt (#560)
Guilherme Oenning86d6c850f505
diff --git a/app/handlers/common.go b/app/handlers/common.goindex de968acff..3bc6ab0fb 100644--- a/app/handlers/common.go+++ b/app/handlers/common.go@@ -72,7 +72,9 @@ func RobotsTXT() web.HandlerFunc {if err != nil {return c.NotFound()}- return c.String(http.StatusOK, string(bytes))+ sitemapURL := c.BaseURL() + "/sitemap.xml"+ content := fmt.Sprintf("%s\nSitemap: %s", bytes, sitemapURL)+ return c.String(http.StatusOK, content)}}diff --git a/app/handlers/common_test.go b/app/handlers/common_test.goindex 9d89391a9..b314cff9e 100644--- a/app/handlers/common_test.go+++ b/app/handlers/common_test.go@@ -54,8 +54,17 @@ func TestRobotsTXT(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()- code, _ := server.Execute(handlers.RobotsTXT())+ code, response := server.+ WithURL("https://demo.test.fider.io/robots.txt").+ Execute(handlers.RobotsTXT())+ content, _ := ioutil.ReadAll(response.Body)Expect(code).Equals(http.StatusOK)+ Expect(string(content)).Equals(`User-agent: *+Disallow: /_api/+Disallow: /api/v1/+Disallow: /admin/+Disallow: /oauth/+Sitemap: https://demo.test.fider.io/sitemap.xml`)}func TestSitemap(t *testing.T) {