feat: add robots.txt setting (close #4303)

This commit is contained in:
Andy Hsu
2023-05-12 16:50:48 +08:00
parent ddc19ab699
commit 5be79eb26e
4 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,10 @@ func Favicon(c *gin.Context) {
c.Redirect(302, setting.GetStr(conf.Favicon))
}
func Robots(c *gin.Context) {
c.String(200, setting.GetStr(conf.RobotsTxt))
}
func Plist(c *gin.Context) {
linkNameB64 := strings.TrimSuffix(c.Param("link_name"), ".plist")
linkName, err := utils.SafeAtob(linkNameB64)

View File

@ -24,6 +24,9 @@ func Init(e *gin.Engine) {
g.Any("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
g.GET("/favicon.ico", handles.Favicon)
g.GET("/robots.txt", handles.Robots)
g.GET("/i/:link_name", handles.Plist)
common.SecretKey = []byte(conf.Conf.JwtSecret)
g.Use(middlewares.StoragesLoaded)
if conf.Conf.MaxConnections > 0 {
@ -31,8 +34,6 @@ func Init(e *gin.Engine) {
}
WebDav(g.Group("/dav"))
g.GET("/favicon.ico", handles.Favicon)
g.GET("/i/:link_name", handles.Plist)
g.GET("/d/*path", middlewares.Down, handles.Down)
g.GET("/p/*path", middlewares.Down, handles.Proxy)