routing changes

This commit is contained in:
Lennart
2025-06-09 17:19:25 +02:00
parent 8f29a468db
commit 2ba0beeafc
6 changed files with 97 additions and 56 deletions

View File

@@ -1,7 +1,6 @@
use axum::Router;
use axum::extract::Request;
use axum::response::{Redirect, Response};
use axum::routing::{any, get};
use axum::response::Response;
use rustical_caldav::caldav_router;
use rustical_carddav::carddav_router;
use rustical_frontend::nextcloud_login::{NextcloudFlows, nextcloud_login_router};
@@ -30,49 +29,31 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
nextcloud_flows_state: Arc<NextcloudFlows>,
) -> Router {
let mut router = Router::new()
.nest(
.merge(caldav_router(
"/caldav",
caldav_router(
"/caldav",
auth_provider.clone(),
cal_store.clone(),
addr_store.clone(),
subscription_store.clone(),
),
)
.nest(
auth_provider.clone(),
cal_store.clone(),
addr_store.clone(),
subscription_store.clone(),
))
.merge(carddav_router(
"/carddav",
carddav_router(
"/carddav",
auth_provider.clone(),
addr_store.clone(),
subscription_store.clone(),
),
)
.route(
"/.well-known/caldav",
any(async || Redirect::permanent("/caldav")),
)
.route(
"/.well-known/carddav",
any(async || Redirect::permanent("/carddav")),
);
auth_provider.clone(),
addr_store.clone(),
subscription_store.clone(),
));
let session_store = MemoryStore::default();
if frontend_config.enabled {
router = router
.nest(
"/frontend",
frontend_router(
auth_provider.clone(),
cal_store.clone(),
addr_store.clone(),
frontend_config,
oidc_config,
session_store.clone(),
),
)
.route("/", get(async || Redirect::to("/frontend")));
router = router.merge(frontend_router(
"/frontend",
auth_provider.clone(),
cal_store.clone(),
addr_store.clone(),
frontend_config,
oidc_config,
session_store.clone(),
));
}
if nextcloud_login_config.enabled {

View File

@@ -9,6 +9,7 @@ use commands::{cmd_gen_config, cmd_pwhash};
use config::{DataStoreConfig, SqliteDataStoreConfig};
use figment::Figment;
use figment::providers::{Env, Format, Toml};
use rustical_dav_push::DavPushController;
use rustical_dav_push::notifier::push_notifier;
use rustical_frontend::nextcloud_login::NextcloudFlows;
use rustical_store::auth::AuthenticationProvider;
@@ -97,12 +98,16 @@ async fn main() -> Result<()> {
let (addr_store, cal_store, subscription_store, principal_store, update_recv) =
get_data_stores(!args.no_migrations, &config.data_store).await?;
let mut tasks = vec![];
if config.dav_push.enabled {
tokio::spawn(push_notifier(
let dav_push_controller = DavPushController::new(
config.dav_push.allowed_push_servers,
update_recv,
subscription_store.clone(),
));
);
tasks.push(tokio::spawn(async move {
dav_push_controller.notifier(update_recv).await;
}));
}
let nextcloud_flows = Arc::new(NextcloudFlows::default());
@@ -126,7 +131,13 @@ async fn main() -> Result<()> {
config.http.host, config.http.port
))
.await?;
axum::serve(listener, app).await?;
tasks.push(tokio::spawn(async {
axum::serve(listener, app).await.unwrap()
}));
for task in tasks {
task.await?;
}
}
}
Ok(())