Skip to main content

Module proxy

Module proxy 

Source
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 None when FIRSTPASS_TENANT_RATE_PER_SEC is 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_middleware so the resolved TenantId is already in request extensions. A no-op (never returns 429) when AppState::tenant_rate_limiter is None.