添加 API 限流和支付渠道熔断

This commit is contained in:
yml2213
2026-06-10 15:48:04 +08:00
parent 0fbe30b377
commit df7d6a2675
7 changed files with 171 additions and 4 deletions
+10
View File
@@ -17,6 +17,7 @@ type Config struct {
SMS SMSConfig
Realname RealnameConfig
Log LogConfig
RateLimit RateLimitConfig
}
type StorageConfig struct {
@@ -48,6 +49,11 @@ type LogConfig struct {
EnableFile bool
}
type RateLimitConfig struct {
Enabled bool
RequestsPerMinute int
}
func Load() Config {
return Config{
AppEnv: getEnv("APP_ENV", "development"),
@@ -82,6 +88,10 @@ func Load() Config {
EnableConsole: getEnvBool("LOG_ENABLE_CONSOLE", true),
EnableFile: getEnvBool("LOG_ENABLE_FILE", true),
},
RateLimit: RateLimitConfig{
Enabled: getEnvBool("RATE_LIMIT_ENABLED", true),
RequestsPerMinute: getEnvInt("RATE_LIMIT_REQUESTS_PER_MINUTE", 300),
},
}
}