mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
27 lines
610 B
Go
27 lines
610 B
Go
package middleware
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/response"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/limiter"
|
|
)
|
|
|
|
func LimiterConfig() fiber.Handler {
|
|
return limiter.New(limiter.Config{
|
|
Max: 20,
|
|
Expiration: 15 * time.Minute,
|
|
LimitReached: func(c *fiber.Ctx) error {
|
|
return c.Status(fiber.StatusTooManyRequests).
|
|
JSON(response.Common{
|
|
Code: fiber.StatusTooManyRequests,
|
|
Status: "error",
|
|
Message: "Too many requests, please try again later",
|
|
})
|
|
},
|
|
SkipSuccessfulRequests: true,
|
|
})
|
|
}
|