feat: add robots.txt and sitemap.xml
This commit is contained in:
@@ -20,6 +20,10 @@ var publicRoutes = []publicRoute{
|
|||||||
{method: http.MethodPost, path: "/login"},
|
{method: http.MethodPost, path: "/login"},
|
||||||
{method: http.MethodGet, path: "/logout"},
|
{method: http.MethodGet, path: "/logout"},
|
||||||
|
|
||||||
|
// Crawler noise.
|
||||||
|
{method: http.MethodGet, path: "/robots.txt"},
|
||||||
|
{method: http.MethodGet, path: "/sitemap.xml"},
|
||||||
|
|
||||||
// Static assets.
|
// Static assets.
|
||||||
{path: "/static", prefix: true},
|
{path: "/static", prefix: true},
|
||||||
{path: "/dist", prefix: true},
|
{path: "/dist", prefix: true},
|
||||||
|
|||||||
@@ -36,6 +36,15 @@ func ProvideRouter(cfg config.Config, htmlRender render.HTMLRender) *gin.Engine
|
|||||||
}
|
}
|
||||||
c.JSON(http.StatusNotFound, ErrorResponse{Error: "Not found"})
|
c.JSON(http.StatusNotFound, ErrorResponse{Error: "Not found"})
|
||||||
})
|
})
|
||||||
|
r.GET("/robots.txt", func(c *gin.Context) {
|
||||||
|
c.String(http.StatusOK, "User-agent: *\nDisallow: /\n")
|
||||||
|
})
|
||||||
|
r.GET("/sitemap.xml", func(c *gin.Context) {
|
||||||
|
c.String(http.StatusOK, `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
</urlset>
|
||||||
|
`)
|
||||||
|
})
|
||||||
r.Static("/static", "./static")
|
r.Static("/static", "./static")
|
||||||
r.Static("/dist", "./dist")
|
r.Static("/dist", "./dist")
|
||||||
r.HTMLRender = htmlRender
|
r.HTMLRender = htmlRender
|
||||||
|
|||||||
Reference in New Issue
Block a user