调整工厂模式的方法

This commit is contained in:
2025-12-05 00:07:15 +08:00
parent 0650feb0d2
commit 6146178111
15 changed files with 635 additions and 1039 deletions

View File

@@ -169,7 +169,7 @@ func RateLimit(config *RateLimitConfig) func(http.Handler) http.Handler {
// 如果没有提供KeyFunc使用默认的客户端IP
if config.KeyFunc == nil {
config.KeyFunc = func(r *http.Request) string {
return getClientIP(r)
return GetClientIP(r)
}
}
@@ -223,7 +223,7 @@ func RateLimitByIP(rate int, windowSize time.Duration) func(http.Handler) http.H
return RateLimit(&RateLimitConfig{
Limiter: NewTokenBucketLimiter(rate, windowSize),
KeyFunc: func(r *http.Request) string {
return getClientIP(r)
return GetClientIP(r)
},
})
}