Skip to content

Commit

Permalink
Merge pull request #392 from xxx7xxxx/fix-ratelimiter-fallback
Browse files Browse the repository at this point in the history
Return resultFallback when it happened
  • Loading branch information
qdongxu committed Sep 6, 2019
2 parents 5c84e71 + e901680 commit bcf3769
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/plugin/ratelimiter/ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const (
// Kind is the kind of RateLimiter.
Kind = "RateLimiter"

resultTimeout = "timeout"
resultTimeout = "timeout"
resultFallback = "fallback"
)

func init() {
Expand Down Expand Up @@ -121,6 +122,7 @@ func (rl *RateLimiter) Handle(ctx context.HTTPContext) string {
if err != nil {
if rl.fallback != nil {
rl.fallback.Fallback(ctx)
return resultFallback
}
ctx.Response().SetStatusCode(http.StatusTooManyRequests)
return resultTimeout
Expand Down

0 comments on commit bcf3769

Please sign in to comment.