feat: add robots.txt and sitemap.xml

This commit is contained in:
2026-06-27 16:30:33 +02:00
parent 87bc6228e7
commit 88c066398e
2 changed files with 13 additions and 0 deletions

View File

@@ -20,6 +20,10 @@ var publicRoutes = []publicRoute{
{method: http.MethodPost, path: "/login"},
{method: http.MethodGet, path: "/logout"},
// Crawler noise.
{method: http.MethodGet, path: "/robots.txt"},
{method: http.MethodGet, path: "/sitemap.xml"},
// Static assets.
{path: "/static", prefix: true},
{path: "/dist", prefix: true},

View File

@@ -36,6 +36,15 @@ func ProvideRouter(cfg config.Config, htmlRender render.HTMLRender) *gin.Engine
}
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("/dist", "./dist")
r.HTMLRender = htmlRender