feat(server): BLE 网关独立限流 — 每网关 60 req/60s

为 /health/gateway 路由添加 gateway_id 级别的速率限制,
网关认证(API Key)→ 限流检查 → handler 三层中间件。
Redis 不可达时同样遵循 fail_close 策略。
This commit is contained in:
iven
2026-05-11 10:24:22 +08:00
parent 0f67f1c21f
commit 533a2b6a8e
2 changed files with 35 additions and 0 deletions

View File

@@ -750,6 +750,10 @@ async fn main() -> anyhow::Result<()> {
.nest(
"/health/gateway",
erp_health::HealthModule::gateway_routes()
.layer(axum::middleware::from_fn_with_state(
state.clone(),
middleware::rate_limit::rate_limit_by_gateway,
))
.layer(axum::middleware::from_fn_with_state(
state.clone(),
erp_health::gateway_auth::gateway_auth_middleware,