Skip to main content

router

Function router 

Source
pub fn router(engine: Arc<MnemoEngine>) -> Router
Expand description

Construct the full Axum router for the Mnemo REST API, reading the bearer-token secret from the MNEMO_AUTH_TOKEN environment variable.

When MNEMO_AUTH_TOKEN is set (non-empty), every request except /v1/health and CORS preflight (OPTIONS) must carry a matching Authorization: Bearer <token> header or it is rejected with 401. When the variable is unset, the server runs open and logs a warning — the floor for “don’t run an unauthenticated memory server” is opt-in but loud.

All routes are nested under /v1/ and the router carries Arc<MnemoEngine> as shared state. CORS is restrictive by default (localhost only); set MNEMO_CORS_ORIGINS to override.