summaryrefslogtreecommitdiffstats
path: root/src/api/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/mod.rs')
-rw-r--r--src/api/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs
index 45eaec4..2cb0415 100644
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -76,6 +76,29 @@ pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) ->
.with_state(state)
}
+/// The HTTP router of a node that only relays (`--relay-only`): its figures and the log
+/// filter (authenticated), and `/health`.
+#[cfg_attr(not(feature = "libp2p"), allow(dead_code))]
+pub(crate) fn relay_only_router(
+ transport: std::sync::Arc<dyn crate::transport::Transport>,
+ auth_state: AuthState,
+) -> Router {
+ let relay = stats::RelayOnly {
+ transport,
+ started: tokio::time::Instant::now(),
+ };
+ Router::new()
+ .route(
+ "/admin/log",
+ get(log::get_log_filter).put(log::put_log_filter),
+ )
+ .route("/admin/stats", get(stats::get_relay_only_stats))
+ .layer(middleware::from_fn_with_state(auth_state, basic_auth))
+ .route("/health", get(health::health))
+ .layer(middleware::from_fn(json_errors))
+ .with_state(relay)
+}
+
/// An error answer: `{"error": message}` with `details`' fields added (`docs/openapi.yaml`,
/// `Error`).
pub(crate) fn error_response(