From ade01e4a91527841f1b73c2420cda1a98dab0a2c Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 10 Jan 2025 15:22:22 +1100 Subject: [PATCH] ccs: web: get settings for a single interface --- charge-controller-supervisor/src/web.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/charge-controller-supervisor/src/web.rs b/charge-controller-supervisor/src/web.rs index d90a297..f98f0bb 100644 --- a/charge-controller-supervisor/src/web.rs +++ b/charge-controller-supervisor/src/web.rs @@ -53,6 +53,7 @@ pub fn rocket(state: ServerState) -> rocket::Rocket { primary_interface, interface, interface_full, + interface_settings, get_control, enable_control, disable_control @@ -155,6 +156,20 @@ async fn interface_full( Ok(Json(data.as_ref().ok_or(ServerError::NoData)?.clone())) } +#[get("/interface//settings")] +async fn interface_settings( + name: &str, + state: &State, +) -> Result, ServerError> { + let data = state + .data + .get(name) + .ok_or(ServerError::NotFound)? + .read_settings() + .await; + Ok(Json(data.as_ref().ok_or(ServerError::NoData)?.clone())) +} + #[get("/metrics")] fn metrics() -> Result { Ok(