Skip to main content

Crate af_web

Crate af_web 

Source
Expand description

af-web — reusable axum web infrastructure (the cross-cutting half of agent_core/api/). Provides:

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 Router preseeded with GET /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).