Expand description
af-web — reusable axum web infrastructure (the cross-cutting half of
agent_core/api/). Provides:
ApiError— JSON error envelope carrying the request id.middleware::request_id/middleware::latency_slo— request-id propagation and the API latency SLO (warn pastmiddleware::SLO_BUDGET_MS).with_standard_middleware— wrap anyRouterwith the standard stack.health— a ready-made health handler.metrics— a minimal Prometheus-compatible liveness metric.
A service composes its product routes and wraps them:
ⓘ
let app = with_standard_middleware(
Router::new().route("/health", get(health)).merge(product_routes),
);Re-exports§
pub use error::ApiError;pub use middleware::latency_slo;pub use middleware::request_id;pub use middleware::RequestId;pub use middleware::SLO_BUDGET_MS;
Modules§
- error
- JSON error envelope. Port of the reusable shape of
agent_core/api/errors.py. - middleware
- Cross-cutting middleware. Ports the reusable concerns of
agent_core/api/: request-id propagation (request_id) and the API latency SLO (latency_slo).
Functions§
- base_
router - A
Routerpreseeded withGET /health. Services merge their routes onto it. - health
- Standard health endpoint payload.
- metrics
- Baseline metric shared by reference hosts. Products merge their own metric families into the same endpoint when they need richer observability.
- with_
standard_ middleware - Wrap a router with the standard middleware stack: latency SLO (outermost, so it times everything) over request-id (so the id exists for SLO logs).