diff options
| author | haturatu <taro@eyes4you.org> | 2025-10-13 02:16:20 +0900 |
|---|---|---|
| committer | haturatu <taro@eyes4you.org> | 2025-10-13 02:16:20 +0900 |
| commit | 6f19c4dcb7702f002d2a1b579f2418e1bc10b18f (patch) | |
| tree | 1fefd40cba9868141e7554e6b59269a341dd00c8 /middleware/ratelimit.go | |
| parent | 1d4b4c0207d7a409d19a32c4f25e8ce68f880c08 (diff) | |
ref(env): config.go
Diffstat (limited to 'middleware/ratelimit.go')
| -rw-r--r-- | middleware/ratelimit.go | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/middleware/ratelimit.go b/middleware/ratelimit.go index 944f863..7ccdf17 100644 --- a/middleware/ratelimit.go +++ b/middleware/ratelimit.go @@ -1,29 +1,18 @@ package middleware import ( + "auth-proxy/config" "auth-proxy/types" "net" "net/http" - "os" - "strconv" "time" ) func NewRateLimiter() *types.RateLimiter { - maxRequests, err := strconv.Atoi(os.Getenv("USER_CREATION_RATE_LIMIT_MAX_REQUESTS")) - if err != nil || maxRequests <= 0 { - maxRequests = 5 // Default value - } - - windowSeconds, err := strconv.Atoi(os.Getenv("USER_CREATION_RATE_LIMIT_WINDOW_SECONDS")) - if err != nil || windowSeconds <= 0 { - windowSeconds = 3600 // Default value (1 hour) - } - return &types.RateLimiter{ Requests: make(map[string][]int64), - Max: maxRequests, - Window: time.Duration(windowSeconds) * time.Second, + Max: config.Paths.RateLimitMaxRequests, + Window: time.Duration(config.Paths.RateLimitWindowSeconds) * time.Second, } } |
