File tree 4 files changed +7
-7
lines changed
4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type Config struct {
23
23
// Default: func(c fiber.Ctx) int {
24
24
// return c.Max
25
25
// }
26
- MaxCalculator func (c fiber.Ctx ) int
26
+ MaxFunc func (c fiber.Ctx ) int
27
27
28
28
// KeyGenerator allows you to generate custom keys, by default c.IP() is used
29
29
//
@@ -109,8 +109,8 @@ func configDefault(config ...Config) Config {
109
109
if cfg .LimiterMiddleware == nil {
110
110
cfg .LimiterMiddleware = ConfigDefault .LimiterMiddleware
111
111
}
112
- if cfg .MaxCalculator == nil {
113
- cfg .MaxCalculator = func (_ fiber.Ctx ) int {
112
+ if cfg .MaxFunc == nil {
113
+ cfg .MaxFunc = func (_ fiber.Ctx ) int {
114
114
return cfg .Max
115
115
}
116
116
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ func (FixedWindow) New(cfg Config) fiber.Handler {
27
27
// Return new handler
28
28
return func (c fiber.Ctx ) error {
29
29
// Generate max from generator, if no generator was provided the default value returned is 5
30
- max := cfg .MaxCalculator (c )
30
+ max := cfg .MaxFunc (c )
31
31
32
32
// Don't execute middleware if Next returns true or if the max is 0
33
33
if (cfg .Next != nil && cfg .Next (c )) || max == 0 {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func (SlidingWindow) New(cfg Config) fiber.Handler {
28
28
// Return new handler
29
29
return func (c fiber.Ctx ) error {
30
30
// Generate max from generator, if no generator was provided the default value returned is 5
31
- max := cfg .MaxCalculator (c )
31
+ max := cfg .MaxFunc (c )
32
32
33
33
// Don't execute middleware if Next returns true or if the max is 0
34
34
if (cfg .Next != nil && cfg .Next (c )) || max == 0 {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ func Test_Limiter_With_Max_Calculator_With_Zero(t *testing.T) {
20
20
app := fiber .New ()
21
21
22
22
app .Use (New (Config {
23
- MaxCalculator : func (_ fiber.Ctx ) int {
23
+ MaxFunc : func (_ fiber.Ctx ) int {
24
24
return 0
25
25
},
26
26
Expiration : 2 * time .Second ,
@@ -61,7 +61,7 @@ func Test_Limiter_With_Max_Calculator(t *testing.T) {
61
61
max := 10
62
62
63
63
app .Use (New (Config {
64
- MaxCalculator : func (_ fiber.Ctx ) int {
64
+ MaxFunc : func (_ fiber.Ctx ) int {
65
65
return max
66
66
},
67
67
Expiration : 2 * time .Second ,
You can’t perform that action at this time.
0 commit comments