Skip to main content

Module admin

Module admin 

Source
Expand description

Admin API and UI server.

Runs an axum [Router] on a dedicated port, separate from the data plane. Exposes Basic-Auth-protected CRUD endpoints for routes and policies, status/health/metrics endpoints, and serves the embedded React SPA (node-graph editor) as an unauthenticated fallback (compile-time ui feature + runtime admin.ui_enabled).

Modulesยง

auth ๐Ÿ”’
HTTP Basic Auth middleware for the admin API.
consumers ๐Ÿ”’
Admin API endpoints for consumer CRUD. Mutations rewrite the in-memory gateway config and trigger SharedState::reload, which rebuilds and atomically swaps the consumer store (no graph recompile is strictly needed, but reload keeps the semantics uniform with routes/policies).
debug ๐Ÿ”’
Admin API for debug mode: trace listing/retrieval and the plugin sandbox.
policies ๐Ÿ”’
Admin API endpoints for policy CRUD, plus catalogs of available plugin types and on-disk scripts. Policy mutations rewrite the in-memory gateway config and trigger validation + graph recompilation via SharedState::reload.
routes ๐Ÿ”’
Admin API endpoints for route CRUD. Mutations rewrite the in-memory gateway config and trigger validation + graph recompilation via SharedState::reload.
status ๐Ÿ”’
Operational endpoints for the admin API: liveness/readiness probes, a status summary, Prometheus metrics, and manual config reload.
ui ๐Ÿ”’
Serves the admin web UI (React SPA node-graph editor) from assets embedded into the binary at build time via rust-embed. Mounted as the admin routerโ€™s unauthenticated fallback; the SPA authenticates its own calls to the admin API.

Functionsยง

build_router ๐Ÿ”’
Builds the admin router: authed API routes, plus โ€” only when compiled with the ui feature AND admin.ui_enabled is true โ€” the unauthenticated SPA fallback. Without it, non-API paths get axumโ€™s default 404.
not_found ๐Ÿ”’
Unauthenticated 404 for non-API paths when the SPA fallback isnโ€™t mounted (ui_enabled: false, or a binary built without the ui feature). See the comment in build_router for why this must be set explicitly rather than left as the routerโ€™s implicit default.
start_admin_server
Binds the admin listener on admin_config.bind:port and serves the admin API and UI until the server exits.