Skip to main content

platform_http/
routes.rs

1use crate::health::{livez, readyz};
2use axum::Router;
3use axum::routing::get;
4use platform_core::AppContext;
5use utoipa_axum::router::OpenApiRouter;
6
7/// Axum router specialized to the shared [`AppContext`] state.
8pub type ApiRouter = Router<AppContext>;
9
10/// `OpenAPI`-aware router specialized to the shared [`AppContext`] state.
11///
12/// Domains and apps build these so that HTTP routes and their `OpenAPI`
13/// documentation come from a single `#[utoipa::path]`-annotated handler.
14pub type ApiOpenApiRouter = OpenApiRouter<AppContext>;
15
16/// Base router with liveness/readiness probes.
17///
18/// These probes are intentionally excluded from the `OpenAPI` contract, so they
19/// are registered as plain routes rather than documented paths.
20pub fn base_router() -> ApiOpenApiRouter {
21    OpenApiRouter::new()
22        .route("/livez", get(livez))
23        .route("/readyz", get(readyz))
24}