You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rate = weightOfPreviousWindow + current window's amount request.
76
79
```
77
80
81
+
## Dynamic limit
82
+
83
+
You can also calculate the limit dynamically using the MaxFunc parameter. It's a function that receives the request's context as a parameter and allow you to calculate a different limit for each request separately.
| Next |`func(fiber.Ctx) bool`| Next defines a function to skip this middleware when returned true. |`nil`|
83
101
| Max |`int`| Max number of recent connections during `Expiration` seconds before sending a 429 response. | 5 |
102
+
| MaxFunc |`func(fiber.Ctx) int`| A function to calculate the max number of recent connections during `Expiration` seconds before sending a 429 response. | A function which returns the cfg.Max |
84
103
| KeyGenerator |`func(fiber.Ctx) string`| KeyGenerator allows you to generate custom keys, by default c.IP() is used. | A function using c.IP() as the default |
85
104
| Expiration |`time.Duration`| Expiration is the time on how long to keep records of requests in memory. | 1 * time.Minute |
86
105
| LimitReached |`fiber.Handler`| LimitReached is called when a request hits the limit. | A function sending 429 response |
@@ -101,6 +120,9 @@ A custom store can be used if it implements the `Storage` interface - more detai
0 commit comments