#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
pub mod error;
pub mod middleware;
use axum::routing::get;
use axum::{Json, Router};
use serde_json::{json, Value};
pub use error::ApiError;
pub use middleware::{latency_slo, request_id, RequestId, SLO_BUDGET_MS};
pub async fn health() -> Json<Value> {
Json(json!({ "status": "ok" }))
}
pub async fn metrics() -> ([(&'static str, &'static str); 1], &'static str) {
(
[("content-type", "text/plain; version=0.0.4")],
"agent_factory_up 1\n",
)
}
pub fn with_standard_middleware<S>(router: Router<S>) -> Router<S>
where
S: Clone + Send + Sync + 'static,
{
router
.layer(axum::middleware::from_fn(latency_slo))
.layer(axum::middleware::from_fn(request_id))
}
pub fn base_router<S>() -> Router<S>
where
S: Clone + Send + Sync + 'static,
{
Router::new()
.route("/health", get(health))
.route("/metrics", get(metrics))
}