add RealUserMiddleware and update resource retrieval to track real users

This commit is contained in:
2025-09-01 17:40:57 +08:00
parent f067e802a2
commit 44b876ba0e
5 changed files with 29 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
package middleware
import (
"strings"
"github.com/gofiber/fiber/v3"
)
func RealUserMiddleware(c fiber.Ctx) error {
userAgent := c.Get("User-Agent")
if strings.Contains(userAgent, "Mozilla") || strings.Contains(userAgent, "AppleWebKit") {
c.Locals("real_user", true)
} else {
c.Locals("real_user", false)
}
return c.Next()
}