Files
telecom-platform/apps/charging-engine/src/rate_limit.rs
T
nutcas3 2094a3b952 refactor: Simplify rate limiter to use default configuration in charging-engine
- Remove unused imports: governor clock/state/Quota, std::num::NonZeroU32, std::sync::Arc, and SmartIpKeyExtractor
- Change create_rate_limiter return type from explicit generic parameters to simple GovernorLayer
- Replace custom rate limit configuration (RATE_LIMIT_RPS, RATE_LIMIT_BURST environment variables) with GovernorConfig::default()
- Remove quota builder logic and pass config directly to GovernorLayer::new()
2026-04-26 02:31:59 +03:00

23 lines
494 B
Rust

use axum::{
http::StatusCode,
response::{IntoResponse, Response},
};
use tower_governor::{
governor::GovernorConfig,
GovernorLayer,
};
pub fn create_rate_limiter() -> GovernorLayer {
let governor_conf = GovernorConfig::default();
GovernorLayer::new(governor_conf)
}
pub struct RateLimitResponse;
impl IntoResponse for RateLimitResponse {
fn into_response(self) -> Response {
(StatusCode::TOO_MANY_REQUESTS, "Rate limit exceeded").into_response()
}
}