mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
Lots of refactoring around routing
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use super::methods::{route_delete, route_propfind, route_proppatch};
|
||||
use super::{PrincipalUri, Resource};
|
||||
use crate::Principal;
|
||||
use actix_web::dev::{AppService, HttpServiceFactory};
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{ResponseError, http::Method, web};
|
||||
use async_trait::async_trait;
|
||||
@@ -47,30 +46,12 @@ pub trait ResourceService: Sized + 'static {
|
||||
|
||||
#[inline]
|
||||
fn actix_resource(self) -> actix_web::Resource {
|
||||
Self::actix_additional_routes(
|
||||
web::resource("")
|
||||
.app_data(Data::new(self))
|
||||
.route(
|
||||
web::method(Method::from_str("PROPFIND").unwrap()).to(route_propfind::<Self>),
|
||||
)
|
||||
.route(
|
||||
web::method(Method::from_str("PROPPATCH").unwrap()).to(route_proppatch::<Self>),
|
||||
)
|
||||
.delete(route_delete::<Self>),
|
||||
)
|
||||
web::resource("")
|
||||
.app_data(Data::new(self))
|
||||
.route(web::method(Method::from_str("PROPFIND").unwrap()).to(route_propfind::<Self>))
|
||||
.route(web::method(Method::from_str("PROPPATCH").unwrap()).to(route_proppatch::<Self>))
|
||||
.delete(route_delete::<Self>)
|
||||
}
|
||||
|
||||
/// Hook for other resources to insert their additional methods (i.e. REPORT, MKCALENDAR)
|
||||
#[inline]
|
||||
fn actix_additional_routes(res: actix_web::Resource) -> actix_web::Resource {
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ResourceServiceRoute<RS: ResourceService>(pub RS);
|
||||
|
||||
impl<RS: ResourceService> HttpServiceFactory for ResourceServiceRoute<RS> {
|
||||
fn register(self, config: &mut AppService) {
|
||||
self.0.actix_resource().register(config);
|
||||
}
|
||||
fn actix_scope(self) -> actix_web::Scope;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user