chore: bump limiter
This commit is contained in:
parent
02e9289058
commit
db76499c13
12
api/main.go
12
api/main.go
|
@ -44,7 +44,11 @@ func main() {
|
|||
ErrorHandler: errorHandler,
|
||||
})
|
||||
app.Use(cors.New())
|
||||
app.Use(limiter.New())
|
||||
app.Use(limiter.New(limiter.Config{
|
||||
Max: 15,
|
||||
Duration: 1 * time.Minute,
|
||||
LimitReached: limitHandler,
|
||||
}))
|
||||
app.Use(etag.New())
|
||||
|
||||
app.Mount("/v1", v1.New())
|
||||
|
@ -65,6 +69,12 @@ func errorHandler(c *fiber.Ctx, err error) error {
|
|||
})
|
||||
}
|
||||
|
||||
func limitHandler(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusTooManyRequests).JSON(fiber.Map{
|
||||
"message": "we only allow up to 15 request per minute",
|
||||
})
|
||||
}
|
||||
|
||||
// StartServerWithGracefulShutdown function for starting server with a graceful shutdown.
|
||||
func StartServerWithGracefulShutdown(a *fiber.App) {
|
||||
// Create channel for idle connections.
|
||||
|
|
Loading…
Reference in New Issue