mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Change how CalDAV/CardDAV services are initialised
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use actix_web::dev::ServiceResponse;
|
use actix_web::dev::{HttpServiceFactory, ServiceResponse};
|
||||||
use actix_web::http::header::{HeaderName, HeaderValue};
|
use actix_web::http::header::{HeaderName, HeaderValue};
|
||||||
use actix_web::http::{Method, StatusCode};
|
use actix_web::http::{Method, StatusCode};
|
||||||
use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
|
use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
|
||||||
@@ -24,20 +24,19 @@ mod subscription;
|
|||||||
|
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
|
||||||
pub fn configure_dav<
|
pub fn caldav_service<
|
||||||
AP: AuthenticationProvider,
|
AP: AuthenticationProvider,
|
||||||
AS: AddressbookStore,
|
AS: AddressbookStore,
|
||||||
C: CalendarStore,
|
C: CalendarStore,
|
||||||
S: SubscriptionStore,
|
S: SubscriptionStore,
|
||||||
>(
|
>(
|
||||||
cfg: &mut web::ServiceConfig,
|
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
store: Arc<C>,
|
store: Arc<C>,
|
||||||
addr_store: Arc<AS>,
|
addr_store: Arc<AS>,
|
||||||
subscription_store: Arc<S>,
|
subscription_store: Arc<S>,
|
||||||
) {
|
) -> impl HttpServiceFactory {
|
||||||
let birthday_store = Arc::new(ContactBirthdayStore::new(addr_store));
|
let birthday_store = Arc::new(ContactBirthdayStore::new(addr_store));
|
||||||
cfg.service(
|
|
||||||
web::scope("")
|
web::scope("")
|
||||||
.wrap(AuthenticationMiddleware::new(auth_provider))
|
.wrap(AuthenticationMiddleware::new(auth_provider))
|
||||||
.wrap(
|
.wrap(
|
||||||
@@ -93,6 +92,5 @@ pub fn configure_dav<
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
).service(subscription_resource::<S>()),
|
).service(subscription_resource::<S>())
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::ServiceResponse,
|
dev::{HttpServiceFactory, ServiceResponse},
|
||||||
http::{
|
http::{
|
||||||
header::{HeaderName, HeaderValue},
|
header::{HeaderName, HeaderValue},
|
||||||
Method, StatusCode,
|
Method, StatusCode,
|
||||||
@@ -25,13 +25,11 @@ pub mod addressbook;
|
|||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod principal;
|
pub mod principal;
|
||||||
|
|
||||||
pub fn configure_dav<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
pub fn carddav_service<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
||||||
cfg: &mut web::ServiceConfig,
|
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
store: Arc<A>,
|
store: Arc<A>,
|
||||||
subscription_store: Arc<S>,
|
subscription_store: Arc<S>,
|
||||||
) {
|
) -> impl HttpServiceFactory {
|
||||||
cfg.service(
|
|
||||||
web::scope("")
|
web::scope("")
|
||||||
.wrap(AuthenticationMiddleware::new(auth_provider))
|
.wrap(AuthenticationMiddleware::new(auth_provider))
|
||||||
.wrap(
|
.wrap(
|
||||||
@@ -79,6 +77,5 @@ pub fn configure_dav<AP: AuthenticationProvider, A: AddressbookStore, S: Subscri
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/app.rs
16
src/app.rs
@@ -2,6 +2,8 @@ use actix_web::body::MessageBody;
|
|||||||
use actix_web::dev::{ServiceFactory, ServiceRequest, ServiceResponse};
|
use actix_web::dev::{ServiceFactory, ServiceRequest, ServiceResponse};
|
||||||
use actix_web::middleware::NormalizePath;
|
use actix_web::middleware::NormalizePath;
|
||||||
use actix_web::{web, App};
|
use actix_web::{web, App};
|
||||||
|
use rustical_caldav::caldav_service;
|
||||||
|
use rustical_carddav::carddav_service;
|
||||||
use rustical_frontend::{configure_frontend, FrontendConfig};
|
use rustical_frontend::{configure_frontend, FrontendConfig};
|
||||||
use rustical_store::auth::AuthenticationProvider;
|
use rustical_store::auth::AuthenticationProvider;
|
||||||
use rustical_store::{AddressbookStore, CalendarStore, SubscriptionStore};
|
use rustical_store::{AddressbookStore, CalendarStore, SubscriptionStore};
|
||||||
@@ -27,23 +29,17 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
|
|||||||
// .wrap(Logger::new("[%s] %r"))
|
// .wrap(Logger::new("[%s] %r"))
|
||||||
.wrap(TracingLogger::default())
|
.wrap(TracingLogger::default())
|
||||||
.wrap(NormalizePath::trim())
|
.wrap(NormalizePath::trim())
|
||||||
.service(web::scope("/caldav").configure(|cfg| {
|
.service(web::scope("/caldav").service(caldav_service(
|
||||||
rustical_caldav::configure_dav(
|
|
||||||
cfg,
|
|
||||||
auth_provider.clone(),
|
auth_provider.clone(),
|
||||||
cal_store.clone(),
|
cal_store.clone(),
|
||||||
addr_store.clone(),
|
addr_store.clone(),
|
||||||
subscription_store.clone(),
|
subscription_store.clone(),
|
||||||
)
|
)))
|
||||||
}))
|
.service(web::scope("/carddav").service(carddav_service(
|
||||||
.service(web::scope("/carddav").configure(|cfg| {
|
|
||||||
rustical_carddav::configure_dav(
|
|
||||||
cfg,
|
|
||||||
auth_provider.clone(),
|
auth_provider.clone(),
|
||||||
addr_store.clone(),
|
addr_store.clone(),
|
||||||
subscription_store,
|
subscription_store,
|
||||||
)
|
)))
|
||||||
}))
|
|
||||||
.service(
|
.service(
|
||||||
web::scope("/.well-known")
|
web::scope("/.well-known")
|
||||||
.service(web::redirect("/caldav", "/caldav"))
|
.service(web::redirect("/caldav", "/caldav"))
|
||||||
|
|||||||
Reference in New Issue
Block a user