feat(config): add rate limit configuration to AppConfig and update related usages
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
pub struct AppConfig {
|
||||
pub allow_registration: bool,
|
||||
pub base_url: String,
|
||||
pub rate_limit: u64,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
@@ -11,6 +12,10 @@ impl AppConfig {
|
||||
.unwrap_or(false);
|
||||
let base_url = std::env::var("BASE_URL")
|
||||
.unwrap_or_else(|_| "http://localhost:3000".to_string());
|
||||
Self { allow_registration, base_url }
|
||||
let rate_limit = std::env::var("RATE_LIMIT")
|
||||
.ok()
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(20);
|
||||
Self { allow_registration, base_url, rate_limit }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user