goshorly/utils/limiter.go
Phil fce20e7c61
All checks were successful
ci/woodpecker/pr/0-pre Pipeline was successful
ci/woodpecker/pr/1-build-check Pipeline was successful
removed renderings to comments
2025-04-09 21:06:28 +02:00

22 lines
499 B
Go

package utils
import (
"time"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
)
var ConfigLimiter limiter.Config = limiter.Config{
Max: 10,
Expiration: 60 * time.Second,
LimitReached: func(c *fiber.Ctx) error {
if c.Get("content-type") == "application/json" {
return c.Status(429).JSON(fiber.Map{
"msg": "Too many requests, slow down I'm a teapot (10 requests per minute)",
"success": false,
})
}
return c.SendStatus(429)
},
}