From ba592de54cd3dce52eb2096dabbe748107f5db2b Mon Sep 17 00:00:00 2001 From: gennyble Date: Fri, 25 Sep 2026 03:56:11 -0500 Subject: splorm auth --- splorm/src/handler/api.rs | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 splorm/src/handler/api.rs (limited to 'splorm/src/handler/api.rs') diff --git a/splorm/src/handler/api.rs b/splorm/src/handler/api.rs deleted file mode 100644 index f360b87..0000000 --- a/splorm/src/handler/api.rs +++ /dev/null @@ -1,43 +0,0 @@ -use axum::{ - Router, - body::Body, - extract::{Path, State}, - response::Response, - routing::get, -}; -use sessionhash::RequestContext; - -use crate::{RuntimeError, fs, state::SplormState}; - -pub fn routes() -> Router { - Router::new().route("/stats/now/{name}", get(stats)) -} - -async fn stats( - Path(name): Path, - State(state): State, - ctx: RequestContext, -) -> Result { - tracing::trace!("{ctx} GET /api/stats/{name}"); - - let graphs = { - let mut connector = state.gatherer_thread().await; - connector.regular_graphs().await - }; - - let file_path = match name.as_str() { - "current_hostmeminfo.gif" => graphs.meminfo, - "current_hostnetinfo.gif" => graphs.meminfo, - "current_hostcpuinfo.gif" => graphs.cpuinfo, - _ => return Err(RuntimeError::generic_404()), - }; - - tracing::trace!("graph {name} system_path={file_path}"); - let file = fs::unsafe_read_file(file_path).await?; - - Response::builder() - .header("content-type", "image/gif") - .status(200) - .body(Body::from(file)) - .map_err(|_| RuntimeError::Unknown) -} -- cgit 1.4.1-3-g733a5