Adds GET /api/v1/admin/system returning disk (scoped to storage_dir via statvfs), memory, CPU, and a server-side alerts array that fires at >90% disk or memory. Disk uses nix::sys::statvfs directly rather than sysinfo's Disks API to avoid mountpoint-matching gymnastics for the storage_dir. A new `Storage::local_root() -> Option<&Path>` trait method exposes the root; the default returns None so a future S3Storage gets `disk: null` in the response instead of fabricated numbers. CPU is sampled inline (refresh → 250ms sleep → refresh → read) so the endpoint adds 250ms of latency per call. No background-cache yet — admin traffic is low-volume and the moving parts aren't worth it until polling shows up. Alerts are evaluated server-side so the frontend can render them without re-implementing the thresholds.
21 lines
550 B
Rust
21 lines
550 B
Rust
//! Admin-only endpoints. Mounted under `/api/v1/admin/*` by
|
|
//! `crate::api::routes`. Every handler in this subtree is guarded by
|
|
//! `RequireAdmin`, which only accepts session-cookie authentication —
|
|
//! bot/API tokens cannot reach admin routes (see
|
|
//! `crate::auth::extractor::RequireAdmin`).
|
|
|
|
pub mod mangas;
|
|
pub mod system;
|
|
pub mod users;
|
|
|
|
use axum::Router;
|
|
|
|
use crate::app::AppState;
|
|
|
|
pub fn routes() -> Router<AppState> {
|
|
Router::new()
|
|
.merge(users::routes())
|
|
.merge(mangas::routes())
|
|
.merge(system::routes())
|
|
}
|