From 0bb3924836205a0364aaf0959c7cf387db004794 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 03:54:19 +0100 Subject: unify closing logic --- src/api/dashboard/mod.rs | 5 +++-- src/api/mod.rs | 13 ++----------- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src/api') diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs index f0cbbfd..0a502a3 100644 --- a/src/api/dashboard/mod.rs +++ b/src/api/dashboard/mod.rs @@ -381,8 +381,9 @@ fn merge_patch(old: &JsonValue, new: &JsonValue) -> Option { } /// The dashboard's routes (authenticated, as the rest of `/admin`), with their hub. -/// `closing` turns true when the node stops (`Hub::closing`). -pub(crate) fn router(state: AppState, closing: watch::Receiver) -> Router { +pub(crate) fn router(state: AppState) -> Router { + // Its streams end when the node shuts down (`AppState::closing`). + let closing = state.closing.subscribe(); Router::new() .route("/admin/dashboard", get(page_html)) .route("/admin/dashboard/state", get(current_state)) diff --git a/src/api/mod.rs b/src/api/mod.rs index 1f178e7..58967f3 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -35,14 +35,7 @@ use crate::state::AppState; /// Builds the complete HTTP router. Everything except the API description (`/swagger-ui`, /// `/openapi.yaml`), `/health` and `/ready` is authenticated. -/// `closing` turns true when the node stops: long-lived responses (the dashboard's -/// events) end then. -pub(crate) fn router( - state: AppState, - auth_state: AuthState, - debug_api: bool, - closing: tokio::sync::watch::Receiver, -) -> Router { +pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) -> Router { let mut api: Router = Router::new() .route("/store", get(store::get_store_root)) .route( @@ -67,10 +60,8 @@ pub(crate) fn router( #[cfg(feature = "dashboard")] { - api = api.merge(dashboard::router(state.clone(), closing)); + api = api.merge(dashboard::router(state.clone())); } - #[cfg(not(feature = "dashboard"))] - let _ = closing; if debug_api { warn!("Debug API enabled"); -- cgit v1.3.1