Expand description
Axum wiring: routes, request/response shapes, and observe-mode trace construction (SPEC §7.1, §7.1a — forward unchanged, record asynchronously, zero added latency).
Structs§
- AppState
- Shared state handed to every request handler. Cheap to clone: an
Arced config, a pooled HTTP client, and a bounded channel sender.
Functions§
- app
- Build the axum router:
POST /v1/messages,GET /v1/capabilities,GET /healthz,GET /metrics. - build_
tenant_ rate_ limiter - Build the per-tenant keyed rate limiter from config (ADR 0004 §D6). Returns
NonewhenFIRSTPASS_TENANT_RATE_PER_SECis unset (the default) — single-operator and existing deployments see no limiter and no behavior change. - tenant_
rate_ limit_ middleware - Axum middleware (ADR 0004 §D6): enforce the per-tenant request rate limit. Must run AFTER
auth_middlewareso the resolvedTenantIdis already in request extensions. A no-op (never returns 429) whenAppState::tenant_rate_limiterisNone.