mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +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::{Method, StatusCode};
|
||||
use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
|
||||
@@ -24,20 +24,19 @@ mod subscription;
|
||||
|
||||
pub use error::Error;
|
||||
|
||||
pub fn configure_dav<
|
||||
pub fn caldav_service<
|
||||
AP: AuthenticationProvider,
|
||||
AS: AddressbookStore,
|
||||
C: CalendarStore,
|
||||
S: SubscriptionStore,
|
||||
>(
|
||||
cfg: &mut web::ServiceConfig,
|
||||
auth_provider: Arc<AP>,
|
||||
store: Arc<C>,
|
||||
addr_store: Arc<AS>,
|
||||
subscription_store: Arc<S>,
|
||||
) {
|
||||
) -> impl HttpServiceFactory {
|
||||
let birthday_store = Arc::new(ContactBirthdayStore::new(addr_store));
|
||||
cfg.service(
|
||||
|
||||
web::scope("")
|
||||
.wrap(AuthenticationMiddleware::new(auth_provider))
|
||||
.wrap(
|
||||
@@ -93,6 +92,5 @@ pub fn configure_dav<
|
||||
)
|
||||
)
|
||||
),
|
||||
).service(subscription_resource::<S>()),
|
||||
);
|
||||
).service(subscription_resource::<S>())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
dev::{HttpServiceFactory, ServiceResponse},
|
||||
http::{
|
||||
header::{HeaderName, HeaderValue},
|
||||
Method, StatusCode,
|
||||
@@ -25,13 +25,11 @@ pub mod addressbook;
|
||||
pub mod error;
|
||||
pub mod principal;
|
||||
|
||||
pub fn configure_dav<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
||||
cfg: &mut web::ServiceConfig,
|
||||
pub fn carddav_service<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
||||
auth_provider: Arc<AP>,
|
||||
store: Arc<A>,
|
||||
subscription_store: Arc<S>,
|
||||
) {
|
||||
cfg.service(
|
||||
) -> impl HttpServiceFactory {
|
||||
web::scope("")
|
||||
.wrap(AuthenticationMiddleware::new(auth_provider))
|
||||
.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::middleware::NormalizePath;
|
||||
use actix_web::{web, App};
|
||||
use rustical_caldav::caldav_service;
|
||||
use rustical_carddav::carddav_service;
|
||||
use rustical_frontend::{configure_frontend, FrontendConfig};
|
||||
use rustical_store::auth::AuthenticationProvider;
|
||||
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(TracingLogger::default())
|
||||
.wrap(NormalizePath::trim())
|
||||
.service(web::scope("/caldav").configure(|cfg| {
|
||||
rustical_caldav::configure_dav(
|
||||
cfg,
|
||||
.service(web::scope("/caldav").service(caldav_service(
|
||||
auth_provider.clone(),
|
||||
cal_store.clone(),
|
||||
addr_store.clone(),
|
||||
subscription_store.clone(),
|
||||
)
|
||||
}))
|
||||
.service(web::scope("/carddav").configure(|cfg| {
|
||||
rustical_carddav::configure_dav(
|
||||
cfg,
|
||||
)))
|
||||
.service(web::scope("/carddav").service(carddav_service(
|
||||
auth_provider.clone(),
|
||||
addr_store.clone(),
|
||||
subscription_store,
|
||||
)
|
||||
}))
|
||||
)))
|
||||
.service(
|
||||
web::scope("/.well-known")
|
||||
.service(web::redirect("/caldav", "/caldav"))
|
||||
|
||||
Reference in New Issue
Block a user