ccs: web: get settings for a single interface

This commit is contained in:
Alex Janka 2025-01-10 15:22:22 +11:00
parent edfc0373db
commit ade01e4a91

View file

@ -53,6 +53,7 @@ pub fn rocket(state: ServerState) -> rocket::Rocket<rocket::Build> {
primary_interface, primary_interface,
interface, interface,
interface_full, interface_full,
interface_settings,
get_control, get_control,
enable_control, enable_control,
disable_control disable_control
@ -155,6 +156,20 @@ async fn interface_full(
Ok(Json(data.as_ref().ok_or(ServerError::NoData)?.clone())) Ok(Json(data.as_ref().ok_or(ServerError::NoData)?.clone()))
} }
#[get("/interface/<name>/settings")]
async fn interface_settings(
name: &str,
state: &State<ServerState>,
) -> Result<Json<crate::controller::ControllerSettings>, 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")] #[get("/metrics")]
fn metrics() -> Result<String, ServerError> { fn metrics() -> Result<String, ServerError> {
Ok( Ok(