jacquardSnapshot

← snapshot

1445 bytes
//! HTTP JSON surface over the in-memory engine, for the web frontend.
//!
//! Honest scope, restated from the architecture's unblock conditions:
//!
//! - **Identities are declared, not authenticated.** A write names an already-registered
//!   actor and the server refuses unknown ids; it never verifies that the caller *is*
//!   that actor. Signing is future work.
//! - **Repos live for the process lifetime.** Every store behind this surface is the
//!   in-memory fake; nothing persists. Persistent stores are a named unblock condition.
//! - **A blocked verdict is a result, not an error.** Promotion endpoints return `200`
//!   for both admitted and blocked; the caller routes a human to the unsettled decisions.

pub mod demo;
mod dto;
mod error;
mod routes;
pub mod state;
mod telemetry_mw;

use axum::{Router, middleware};
pub use state::{AppState, SharedState};
use tower_http::cors::CorsLayer;

/// Builds the router over shared state.
///
/// CORS is permissive because there is nothing to protect: no credential is
/// accepted anywhere on this surface, honestly. Every request passes through
/// one `http.server.request` telemetry span (skipped for `/api/health`).
pub fn app(state: SharedState) -> Router {
    routes::router()
        .layer(middleware::from_fn_with_state(
            state.clone(),
            telemetry_mw::span_middleware,
        ))
        .layer(CorsLayer::permissive())
        .with_state(state)
}