Skip to content

Commit 4915e16

Browse files
committed
update deps
1 parent bfbbd02 commit 4915e16

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## echo_limiter is middleware for echo framework
22

3-
echo_limiter using [redis](https://github.com/go-redis/redis) as store for rate limit with two algorithms for choosing simple, gcra [leaky bucket](https://en.wikipedia.org/wiki/Leaky_bucket)
3+
echo_limiter using [redis](https://github.com/go-redis/redis) as store for rate limit with two algorithms for choosing sliding window, gcra [leaky bucket](https://en.wikipedia.org/wiki/Leaky_bucket)
44

55
### Install
66
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ go 1.14
55
require (
66
github.com/go-redis/redis/v7 v7.2.0
77
github.com/labstack/echo/v4 v4.1.16
8-
github.com/shareed2k/go_limiter v0.0.5
8+
github.com/shareed2k/go_limiter v0.0.6
99
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 // indirect
1010
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
4545
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
4646
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4747
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
48-
github.com/shareed2k/go_limiter v0.0.5 h1:v6JhDd/rp5aGum4HYg7Ko0k/ATQtj91OXP0AsrWuGsY=
49-
github.com/shareed2k/go_limiter v0.0.5/go.mod h1:YD+giVRK4A6t4OpIdsQP716pXuL2+Fp52B7LfyNI5m0=
48+
github.com/shareed2k/go_limiter v0.0.6 h1:iySeSnJ17B4Xs7ctb5Cb5H/ogGbtT66L/GZoMEGFEjA=
49+
github.com/shareed2k/go_limiter v0.0.6/go.mod h1:YD+giVRK4A6t4OpIdsQP716pXuL2+Fp52B7LfyNI5m0=
5050
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5151
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
5252
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=

main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
)
1414

1515
const (
16-
SimpleAlgorithm = "simple"
17-
GCRAAlgorithm = "gcra"
18-
DefaultKeyPrefix = "echo_limiter"
19-
defaultMessage = "Too many requests, please try again later."
20-
defaultStatusCode = http.StatusTooManyRequests
16+
SlidingWindowAlgorithm = go_limiter.SlidingWindowAlgorithm
17+
GCRAAlgorithm = go_limiter.GCRAAlgorithm
18+
DefaultKeyPrefix = "echo_limiter"
19+
defaultMessage = "Too many requests, please try again later."
20+
defaultStatusCode = http.StatusTooManyRequests
2121
)
2222

2323
var (
@@ -28,7 +28,7 @@ var (
2828
StatusCode: defaultStatusCode,
2929
Message: defaultMessage,
3030
Prefix: DefaultKeyPrefix,
31-
Algorithm: SimpleAlgorithm,
31+
Algorithm: SlidingWindowAlgorithm,
3232
Period: time.Minute,
3333
Key: func(ctx echo.Context) string {
3434
return ctx.RealIP()
@@ -59,8 +59,8 @@ type (
5959
Message string
6060

6161
// Algorithm
62-
// Default: simple
63-
Algorithm string
62+
// Default: sliding window
63+
Algorithm uint
6464

6565
// Prefix
6666
// Default:
@@ -124,7 +124,7 @@ func NewWithConfig(config Config) echo.MiddlewareFunc {
124124
config.Message = DefaultConfig.Message
125125
}
126126

127-
if config.Algorithm == "" {
127+
if config.Algorithm == 0 {
128128
config.Algorithm = DefaultConfig.Algorithm
129129
}
130130

0 commit comments

Comments
 (0)