diff options
Diffstat (limited to 'src/api/mod.rs')
| -rw-r--r-- | src/api/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index fd05669..3f60cd6 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -35,7 +35,14 @@ use crate::state::AppState; /// Builds the complete HTTP router. Everything except the API description (`/swagger-ui`, /// `/openapi.yaml`), `/health` and `/ready` is authenticated. -pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) -> Router { +/// `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<bool>, +) -> Router { let mut api: Router<AppState> = Router::new() .route("/store", get(store::get_store_root)) .route( @@ -59,8 +66,10 @@ pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) -> #[cfg(feature = "dashboard")] { - api = api.merge(dashboard::router(state.clone())); + api = api.merge(dashboard::router(state.clone(), closing)); } + #[cfg(not(feature = "dashboard"))] + let _ = closing; if debug_api { warn!("Debug API enabled"); |
