use switch for RobotsHeaders

This commit is contained in:
tobi 2025-02-05 12:19:39 +01:00
commit 5fa33bcad5

View file

@ -41,25 +41,27 @@ func RobotsHeaders(mode string) gin.HandlerFunc {
noai = "noai, noimageai" noai = "noai, noimageai"
) )
if mode == "aiOnly" { switch mode {
// Just set ai headers and
// leave the other headers be. // Just set ai headers and
// leave the other headers be.
case "aiOnly":
return func(c *gin.Context) { return func(c *gin.Context) {
c.Writer.Header().Set(key, noai) c.Writer.Header().Set(key, noai)
} }
}
if mode == "allowSome" { // Allow some limited indexing.
// Allow some limited indexing. case "allowSome":
return func(c *gin.Context) { return func(c *gin.Context) {
c.Writer.Header().Set(key, apiutil.RobotsDirectivesAllowSome) c.Writer.Header().Set(key, apiutil.RobotsDirectivesAllowSome)
c.Writer.Header().Add(key, noai) c.Writer.Header().Add(key, noai)
} }
}
// Disallow indexing via noindex, nofollow. // Disallow indexing via noindex, nofollow.
return func(c *gin.Context) { default:
c.Writer.Header().Set(key, apiutil.RobotsDirectivesDisallow) return func(c *gin.Context) {
c.Writer.Header().Add(key, noai) c.Writer.Header().Set(key, apiutil.RobotsDirectivesDisallow)
c.Writer.Header().Add(key, noai)
}
} }
} }