Comments (5)
Here is an example with app.Use
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
)
func main() {
app := fiber.New()
// โฆ
// Custom rate limits for specific paths
app.Use("/auth", limiter.New(limiter.Config{
Max: 10, // Requests per minute for /auth
Expiration: 1 * time.Minute,
}))
app.Use("/auth/", limiter.New(limiter.Config{
Max: 5, // Requests per minute for /auth/
Expiration: 1 * time.Minute,
}))
app.Use("/auth/realms", limiter.New(limiter.Config{
Max: 25, // Requests per minute for /auth/realms
Expiration: 1 * time.Minute,
}))
// Add your routes here
app.Get("/auth", handler.RedirectHandler)
app.Get("/auth/", handler.RedirectHandler)
app.Get("/auth/realms", handler.RedirectHandler)
// โฆ
// Start the server
app.Listen(":3000")
}
from fiber.
Thanks for opening your first issue here! ๐ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
from fiber.
Is anyone know decision?
from fiber.
Yes. You can use a new rate limiter middleware handler for each route.
Either set a route on app.Use
with the middleware handler (works with groups too), or apply the handler in the app.Get
https://docs.gofiber.io/guide/routing#middleware
from fiber.
@sixcolors thanks I did the same way and it works
from fiber.
Related Issues (20)
- Explore Performance Optimization: Using a Pool for Memory Allocation in Client Package HOT 1
- Update Documentation and README.md for Client Package Refactor HOT 1
- ๐ [Bug]: local variable based on ctx.Method() is changed in goroutine HOT 5
- ๐ค [Question]: How can i keep a connection alive untill timeout or i response some message? HOT 1
- ๐ค [Question]: Custom Listen Function HOT 3
- CSRF Trusted Origins HOT 2
- ๐งน [Maintenance]: Update RFC Draft for Idempotency Middleware HOT 1
- Have I found a bug in BodyParser, or am I an idiot? HOT 4
- ๐ [Bug]: CORS middleware misclassifies all OPTIONS requests as preflight requests HOT 1
- ๐ค [Question]: How do I get default logger to log error HOT 2
- ๐ค [Question]: how to Get status code in middleware HOT 5
- ๐ [Proposal]: Add Helpers for Internal IP Ranges HOT 4
- ๐ [Bug]: version v2.52.2 up to v2.52.3 , cors error HOT 22
- ๐ [Bug]: serving a compress enabled public folder without +w permissions results in a 404 HOT 3
- ๐ *** CLOSE - I see Context( ) returns this type .... *** - r4[Proposal]: Add RequestCtx in ctx that returns *fasthttp from DefaultCtx HOT 5
- ๐ [Bug]: CORS issue HOT 2
- ๐ [Proposal]: Allow disabling cache for ctx.SendFile() HOT 2
- ๐ [Bug]: Data race on shutdown HOT 8
- ๐ค [Question]: Calling other endpoints without network HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.