mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat/login crud in users sync with sso
This commit is contained in:
@@ -24,3 +24,24 @@ func LimiterConfig() fiber.Handler {
|
||||
SkipSuccessfulRequests: true,
|
||||
})
|
||||
}
|
||||
|
||||
func NewLimiter(max int, expiration time.Duration) fiber.Handler {
|
||||
if max <= 0 {
|
||||
max = 10
|
||||
}
|
||||
if expiration <= 0 {
|
||||
expiration = time.Minute
|
||||
}
|
||||
return limiter.New(limiter.Config{
|
||||
Max: max,
|
||||
Expiration: expiration,
|
||||
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",
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user