Minor refactoring and tracing

This commit is contained in:
Lennart
2024-10-04 19:42:44 +02:00
parent 8ed0c3ec2a
commit 6bc1ac6a7d
6 changed files with 9 additions and 6 deletions

View File

@@ -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 = ();

View File

@@ -1,4 +1,4 @@
pub mod depth_extractor;
pub mod depth_header;
pub mod error;
pub mod methods;
pub mod namespace;

View File

@@ -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<R: ResourceService>(
path_components: Path<R::PathComponents>,
body: String,

View File

@@ -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<T> {
operations: Vec<Operation<T>>,
}
#[instrument(parent = root_span.id(), skip(path, req, root_span))]
pub async fn route_proppatch<R: ResourceService>(
path: Path<R::PathComponents>,
body: String,
req: HttpRequest,
user: User,
root_span: RootSpan,
) -> Result<MultistatusElement<PropstatWrapper<String>, PropstatWrapper<String>>, R::Error> {
let path_components = path.into_inner();
let href = req.path().to_owned();

View File

@@ -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<T1: Serialize, T2: Serialize> Responder for MultistatusElement<T1, T2> {
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())