mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-13 15:35:13 +00:00
refactor: Replace unwrap() with unwrap_or_else fallback in rate limiter configuration
- Add fallback to default GovernorConfig (10 req/s, burst 20) if custom config fails - Replace unwrap() with unwrap_or_else providing sensible defaults - Add comment explaining fallback behavior for rate limiter initialization
This commit is contained in:
@@ -37,7 +37,14 @@ pub fn create_router(state: AppState) -> Router {
|
|||||||
.per_second(requests_per_second as u64)
|
.per_second(requests_per_second as u64)
|
||||||
.burst_size(burst_size)
|
.burst_size(burst_size)
|
||||||
.finish()
|
.finish()
|
||||||
.unwrap();
|
.unwrap_or_else(|_| {
|
||||||
|
// Fallback to default config if builder fails
|
||||||
|
GovernorConfigBuilder::default()
|
||||||
|
.per_second(10)
|
||||||
|
.burst_size(20)
|
||||||
|
.finish()
|
||||||
|
.expect("Default governor config should never fail")
|
||||||
|
});
|
||||||
|
|
||||||
Router::new()
|
Router::new()
|
||||||
// Public routes (no auth required - for packet-gateway integration)
|
// Public routes (no auth required - for packet-gateway integration)
|
||||||
|
|||||||
Reference in New Issue
Block a user