build_router

Function build_router 

Source
pub fn build_router(state: Arc<ServerState>) -> Router
Expand description

Build the axum router with all API endpoints and OpenAPI doc routes.

Structure:

  • /v2/* — the main resource router, with the global ServerState::request_timeout applied as an outer TimeoutLayer. POST /power now returns immediately with a PCS transition id (the polling loop runs CLI-side), so it fits well under the default timeout — no per-route override is needed.
  • /v2/auth/* — separate sub-router with two layered defences: per-IP rate limit (see AuthRateLimiter) and body redaction from any log span (see strip_body_for_logs). No Bearer-token extractor (these endpoints issue the token).
  • /docs + /openapi.json — Swagger UI and the spec from ApiDoc.
  • HSTS header injected on every response by an add_hsts_header middleware (private to this module).