Added limiter json
This commit is contained in:
parent
9831a7c0b4
commit
44e7b3066c
1 changed files with 6 additions and 0 deletions
|
@ -11,6 +11,12 @@ var ConfigLimiter limiter.Config = limiter.Config{
|
||||||
Max: 10,
|
Max: 10,
|
||||||
Expiration: 60 * time.Second,
|
Expiration: 60 * time.Second,
|
||||||
LimitReached: func(c *fiber.Ctx) error {
|
LimitReached: func(c *fiber.Ctx) error {
|
||||||
|
if c.Get("content-type") == "application/json" {
|
||||||
|
return c.Status(418).JSON(fiber.Map{
|
||||||
|
"msg": "Too many requests, slow down I'm a teapot (10 requests per minute)",
|
||||||
|
"success": false,
|
||||||
|
})
|
||||||
|
}
|
||||||
return c.Render("views/home", fiber.Map{
|
return c.Render("views/home", fiber.Map{
|
||||||
"ERR": "You have reached the limit of requests! Please check back later. (1 minute)",
|
"ERR": "You have reached the limit of requests! Please check back later. (1 minute)",
|
||||||
"CI_COMMIT_SHORT_SHA": CI_COMMIT_SHORT_SHA,
|
"CI_COMMIT_SHORT_SHA": CI_COMMIT_SHORT_SHA,
|
||||||
|
|
Loading…
Reference in a new issue