diff --git a/backend/src/api.rs b/backend/src/api.rs index b763c4e..1452ee1 100644 --- a/backend/src/api.rs +++ b/backend/src/api.rs @@ -74,14 +74,18 @@ pub(crate) async fn listen(sender: web::Data>) -> Result, datastore: web::Data>) -> Result { +pub(crate) async fn get_setting_by_name(name: web::Path) -> Result { + trace!("HTTP GET /setting/{name}"); + let result = CONFIG.read().await.get_property(&name)?; Ok(result) } #[post("/setting/{name}")] #[instrument] -pub(crate) async fn set_setting_by_name(body: Bytes, name: web::Path, datastore: web::Data>) -> Result { +pub(crate) async fn set_setting_by_name(body: Bytes, name: web::Path) -> Result { + trace!("HTTP POST /setting/{name}"); + let value = String::from_utf8(body.to_vec()).map_err(|_| Error::from_str("Unable to decode body as utf8"))?; CONFIG.write().await.set_property(&name, &value)?; Ok(HttpResponse::Ok())