From 6bc1ac6a7de26a12cc847aebb8c3abb84fee447c Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Fri, 4 Oct 2024 19:42:44 +0200 Subject: [PATCH] Minor refactoring and tracing --- crates/caldav/src/root/mod.rs | 4 ++-- crates/dav/src/{depth_extractor.rs => depth_header.rs} | 0 crates/dav/src/lib.rs | 2 +- crates/dav/src/methods/propfind.rs | 3 ++- crates/dav/src/methods/proppatch.rs | 4 ++++ crates/dav/src/xml/multistatus.rs | 2 -- 6 files changed, 9 insertions(+), 6 deletions(-) rename crates/dav/src/{depth_extractor.rs => depth_header.rs} (100%) diff --git a/crates/caldav/src/root/mod.rs b/crates/caldav/src/root/mod.rs index 29fba4c..bdc77bb 100644 --- a/crates/caldav/src/root/mod.rs +++ b/crates/caldav/src/root/mod.rs @@ -8,8 +8,6 @@ use rustical_dav::xml::HrefElement; use serde::{Deserialize, Serialize}; use strum::{EnumString, VariantNames}; -pub struct RootResourceService; - #[derive(EnumString, Debug, VariantNames, Clone)] #[strum(serialize_all = "kebab-case")] pub enum RootPropName { @@ -68,6 +66,8 @@ impl Resource for RootResource { } } +pub struct RootResourceService; + #[async_trait(?Send)] impl ResourceService for RootResourceService { type PathComponents = (); diff --git a/crates/dav/src/depth_extractor.rs b/crates/dav/src/depth_header.rs similarity index 100% rename from crates/dav/src/depth_extractor.rs rename to crates/dav/src/depth_header.rs diff --git a/crates/dav/src/lib.rs b/crates/dav/src/lib.rs index f9986d7..7245c56 100644 --- a/crates/dav/src/lib.rs +++ b/crates/dav/src/lib.rs @@ -1,4 +1,4 @@ -pub mod depth_extractor; +pub mod depth_header; pub mod error; pub mod methods; pub mod namespace; diff --git a/crates/dav/src/methods/propfind.rs b/crates/dav/src/methods/propfind.rs index 502dc33..42fc254 100644 --- a/crates/dav/src/methods/propfind.rs +++ b/crates/dav/src/methods/propfind.rs @@ -1,4 +1,4 @@ -use crate::depth_extractor::Depth; +use crate::depth_header::Depth; use crate::resource::Resource; use crate::resource::ResourceService; use crate::xml::multistatus::PropstatWrapper; @@ -35,6 +35,7 @@ struct PropfindElement { } #[instrument(parent = root_span.id(), skip(path_components, req, root_span))] +#[allow(clippy::type_complexity)] pub async fn route_propfind( path_components: Path, body: String, diff --git a/crates/dav/src/methods/proppatch.rs b/crates/dav/src/methods/proppatch.rs index 0f7fe2a..bd53616 100644 --- a/crates/dav/src/methods/proppatch.rs +++ b/crates/dav/src/methods/proppatch.rs @@ -12,6 +12,8 @@ use log::debug; use rustical_store::auth::User; use serde::{Deserialize, Serialize}; use std::str::FromStr; +use tracing::instrument; +use tracing_actix_web::RootSpan; // https://docs.rs/quick-xml/latest/quick_xml/de/index.html#normal-enum-variant #[derive(Deserialize, Serialize, Clone, Debug)] @@ -47,11 +49,13 @@ struct PropertyupdateElement { operations: Vec>, } +#[instrument(parent = root_span.id(), skip(path, req, root_span))] pub async fn route_proppatch( path: Path, body: String, req: HttpRequest, user: User, + root_span: RootSpan, ) -> Result, PropstatWrapper>, R::Error> { let path_components = path.into_inner(); let href = req.path().to_owned(); diff --git a/crates/dav/src/xml/multistatus.rs b/crates/dav/src/xml/multistatus.rs index aa0c490..eae7f7f 100644 --- a/crates/dav/src/xml/multistatus.rs +++ b/crates/dav/src/xml/multistatus.rs @@ -2,7 +2,6 @@ use crate::{namespace::Namespace, xml::TagList}; use actix_web::{ body::BoxBody, http::header::ContentType, HttpRequest, HttpResponse, Responder, ResponseError, }; -use log::debug; use serde::Serialize; // Intermediate struct because of a serde limitation, see following article: @@ -94,7 +93,6 @@ impl Responder for MultistatusElement { if let Err(err) = self.serialize(ser) { return crate::Error::from(err).error_response(); } - // debug!("Return multistatus:\n{output}"); HttpResponse::MultiStatus() .content_type(ContentType::xml())