Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Traceing to settings api
Browse files Browse the repository at this point in the history
CEbbinghaus committed Dec 17, 2024
1 parent 932d880 commit 7353f93
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
@@ -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())

0 comments on commit 7353f93

Please sign in to comment.