Expand description
bhtune-server — the Axum HTTP/REST adapter over bhtune-core/bhtune-db, and the host
for the built React SPA (embedded via rust-embed, server-embed-spa). See AGENTS.md’s
“Web app architecture” section for why this, rather than a desktop GUI, is the primary
v1 GUI adapter.
Split into a lib (this crate, bhtune_server) and a thin main.rs binary shell so route
handlers are directly testable via [tower::ServiceExt::oneshot] against
build_router’s output, with no bound TCP socket needed – the same lib/bin split
bhtune-cli already uses for the same reason.
Re-exports§
pub use state::AppState;
Modules§
- active_
run ActiveRun: tracks every tune run currently executing in a background task, socrate::routes::runscan cancel one specific run and graceful shutdown can cancel and wait for all in-flight runs to be restored before the process actually exits.- cli
bhtune-server’s CLI surface (server-windows-service): a--configflag plus five subcommands (install/uninstall/start/stop/status) that manage this binary’s registration as a platform service.- error
ApiError: the one error type every route handler returns, and its mapping onto an HTTP status code plus a JSON{"error": "..."}body.- openapi
ApiDoc: the single [utoipa::OpenApi] aggregator listing every route and schema this crate serves. Kept as its own module (rather than folded intolib.rs) because this list is the one place that must be updated whenever a route or DTO is added – a dedicated file makes that omission easy to spot in a diff.- routes
- HTTP route modules, one per resource. Each exposes a plain
pub fn router() -> axum::Router<AppState>, merged together incrate::build_router. - run
- The actual
bhtune-serverbootstrap-and-serve sequence, split out ofmain.rsso it can be driven two different ways (server-windows-service): directly, from an interactive console session or a systemd/launchd-managed foreground process, or from inside the Windows Service Control Manager’s own callback thread (crate::service’s#[cfg(windows)]glue), which needs its own shutdown trigger (an SCM Stop/Shutdown control event) instead of Ctrl+C/SIGTERM. - security
- service
- Platform service registration and lifecycle management (
server-windows-service). - state
AppState: the shared state every route handler receives viaaxum::extract::State.
Functions§
- build_
router - Assembles every route module into one [
axum::Router], ready to serve or to drive directly in a test viatower::ServiceExt::oneshot.