Skip to content

Commit

Permalink
Added Traceing to settings api
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Sep 22, 2024
1 parent d936423 commit 6d3708f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ pub(crate) async fn listen(sender: web::Data<Sender<CardEvent>>) -> Result<HttpR

#[get("/setting/{name}")]
#[instrument]
pub(crate) async fn get_setting_by_name(name: web::Path<String>, datastore: web::Data<Arc<Store>>) -> Result<impl Responder> {
pub(crate) async fn get_setting_by_name(name: web::Path<String>) -> Result<impl Responder> {
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<String>, datastore: web::Data<Arc<Store>>) -> Result<impl Responder> {
pub(crate) async fn set_setting_by_name(body: Bytes, name: web::Path<String>) -> Result<impl Responder> {
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())
Expand Down

0 comments on commit 6d3708f

Please sign in to comment.