feat(saas): add quota check middleware for relay requests

Injects billing quota verification before relay chat completion requests.
Checks monthly relay_requests quota via billing::service::check_quota.
Gracefully degrades on quota service failure (logs warning, allows request).
This commit is contained in:
iven
2026-04-02 00:03:26 +08:00
parent 9487cd7f72
commit d06ecded34
2 changed files with 56 additions and 20 deletions

View File

@@ -368,6 +368,10 @@ async fn build_router(state: AppState) -> axum::Router {
state.clone(),
zclaw_saas::middleware::request_id_middleware,
))
.layer(middleware::from_fn_with_state(
state.clone(),
zclaw_saas::middleware::quota_check_middleware,
))
.layer(middleware::from_fn_with_state(
state.clone(),
zclaw_saas::middleware::rate_limit_middleware,