mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-22 11:29:29 +00:00
Massive refactoring how DAV resources and routes work
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::principal::PrincipalResource;
|
||||
use crate::Error;
|
||||
use actix_web::dev::ResourceMap;
|
||||
use actix_web::HttpRequest;
|
||||
use async_trait::async_trait;
|
||||
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
||||
@@ -47,14 +49,23 @@ impl Resource for RootResource {
|
||||
type Prop = RootProp;
|
||||
type Error = Error;
|
||||
|
||||
fn get_prop(&self, prefix: &str, prop: Self::PropName) -> Result<Self::Prop, Self::Error> {
|
||||
fn get_prop(
|
||||
&self,
|
||||
rmap: &ResourceMap,
|
||||
prop: Self::PropName,
|
||||
) -> Result<Self::Prop, Self::Error> {
|
||||
Ok(match prop {
|
||||
RootPropName::Resourcetype => RootProp::Resourcetype(Resourcetype::default()),
|
||||
RootPropName::CurrentUserPrincipal => RootProp::CurrentUserPrincipal(HrefElement::new(
|
||||
format!("{}/user/{}/", prefix, self.principal),
|
||||
PrincipalResource::get_url(rmap, vec![&self.principal]).unwrap(),
|
||||
)),
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn resource_name() -> &'static str {
|
||||
"caldav_root"
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
|
||||
Reference in New Issue
Block a user