mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +00:00
Checkpoint: Migration to axum
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
#[cfg(feature = "actix")]
|
||||
use super::methods::{actix_route_delete, actix_route_propfind, actix_route_proppatch};
|
||||
use super::{PrincipalUri, Resource};
|
||||
use crate::Principal;
|
||||
#[cfg(feature = "axum")]
|
||||
use crate::resource::{AxumMethods, AxumService};
|
||||
#[cfg(feature = "actix")]
|
||||
use actix_web::{http::Method, web, web::Data};
|
||||
use async_trait::async_trait;
|
||||
use serde::Deserialize;
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
|
||||
#[async_trait]
|
||||
pub trait ResourceService: Sized + Send + Sync + 'static {
|
||||
@@ -28,11 +22,6 @@ pub trait ResourceService: Sized + Send + Sync + 'static {
|
||||
Ok(vec![])
|
||||
}
|
||||
|
||||
async fn test_get_members(&self, _path: &Self::PathComponents) -> Result<String, Self::Error> {
|
||||
// ) -> Result<Vec<Self::MemberType>, Self::Error> {
|
||||
Ok("asd".to_string())
|
||||
}
|
||||
|
||||
async fn get_resource(
|
||||
&self,
|
||||
_path: &Self::PathComponents,
|
||||
@@ -54,36 +43,10 @@ pub trait ResourceService: Sized + Send + Sync + 'static {
|
||||
Err(crate::Error::Unauthorized.into())
|
||||
}
|
||||
|
||||
#[cfg(feature = "actix")]
|
||||
#[inline]
|
||||
fn actix_resource(self) -> actix_web::Resource
|
||||
where
|
||||
Self::Error: actix_web::ResponseError,
|
||||
Self::Principal: actix_web::FromRequest,
|
||||
{
|
||||
web::resource("")
|
||||
.app_data(Data::new(self))
|
||||
.route(
|
||||
web::method(Method::from_str("PROPFIND").unwrap()).to(actix_route_propfind::<Self>),
|
||||
)
|
||||
.route(
|
||||
web::method(Method::from_str("PROPPATCH").unwrap())
|
||||
.to(actix_route_proppatch::<Self>),
|
||||
)
|
||||
.delete(actix_route_delete::<Self>)
|
||||
}
|
||||
|
||||
#[cfg(feature = "actix")]
|
||||
fn actix_scope(self) -> actix_web::Scope
|
||||
where
|
||||
Self::Error: actix_web::ResponseError,
|
||||
Self::Principal: actix_web::FromRequest;
|
||||
|
||||
#[cfg(feature = "axum")]
|
||||
fn axum_service(self) -> AxumService<Self>
|
||||
where
|
||||
Self: Clone + Send + Sync + AxumMethods,
|
||||
{
|
||||
AxumService::new(Arc::new(self))
|
||||
AxumService::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user