mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2025-12-06 14:59:18 +08:00
feat:add robots.txt
This commit is contained in:
@@ -59,6 +59,19 @@ func Static(r *gin.Engine, noRoute func(handlers ...gin.HandlerFunc)) {
|
||||
c.Status(http.StatusOK)
|
||||
_, _ = io.Copy(c.Writer, faviconFile)
|
||||
})
|
||||
r.GET("/robots.txt", func(c *gin.Context) {
|
||||
robotFile, err := static.Open("robots.txt")
|
||||
if err != nil {
|
||||
zlog.Error("can't find robots.txt")
|
||||
c.Status(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
defer robotFile.Close()
|
||||
|
||||
c.Header("Content-Type", "text/plain")
|
||||
c.Status(http.StatusOK)
|
||||
_, _ = io.Copy(c.Writer, robotFile)
|
||||
})
|
||||
|
||||
noRoute(func(c *gin.Context) {
|
||||
c.Header("Content-Type", "text/html")
|
||||
|
||||
Reference in New Issue
Block a user