feat: add Redis based rate limiting for multiple instances
This commit is contained in:
@@ -30,7 +30,7 @@ func (blockList AccessListMiddleware) AccessMiddleware(next http.Handler) http.H
|
||||
for _, block := range blockList.List {
|
||||
if isPathBlocked(r.URL.Path, util.ParseURLPath(blockList.Path+block)) {
|
||||
logger.Error("%s: %s access forbidden", getRealIP(r), r.URL.Path)
|
||||
RespondWithError(w, http.StatusForbidden, fmt.Sprintf("%d you do not have permission to access this resource", http.StatusForbidden), blockList.ErrorInterceptor)
|
||||
RespondWithError(w, http.StatusForbidden, fmt.Sprintf("%d you do not have permission to access this resource"))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func isPathBlocked(requestPath, blockedPath string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// NewRateLimiter creates a new rate limiter with the specified refill rate and token capacity
|
||||
// NewRateLimiter creates a new requests limiter with the specified refill requests and token capacity
|
||||
func NewRateLimiter(maxTokens int, refillRate time.Duration) *TokenRateLimiter {
|
||||
return &TokenRateLimiter{
|
||||
tokens: maxTokens,
|
||||
|
||||
Reference in New Issue
Block a user