mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-10-23 06:01:16 +00:00
Add API handler for general node info
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
1 file changed
+16
+16
@@ -101,6 +101,7 @@ impl Http {
|
||||
message_stack,
|
||||
};
|
||||
let admin_routes = Router::new()
|
||||
.route("/admin", get(get_info))
|
||||
.route("/admin/peers", get(get_peers))
|
||||
.route("/admin/routes/selected", get(get_selected_routes))
|
||||
.route("/admin/routes/fallback", get(get_fallback_routes))
|
||||
@@ -398,6 +399,21 @@ async fn get_fallback_routes(State(state): State<HttpServerState>) -> Json<Vec<R
|
||||
Json(routes)
|
||||
}
|
||||
|
||||
/// General info about a node.
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Info {
|
||||
/// The overlay subnet in use by the node.
|
||||
pub node_subnet: String,
|
||||
}
|
||||
|
||||
/// Get general info about the node.
|
||||
async fn get_info(State(state): State<HttpServerState>) -> Json<Info> {
|
||||
Json(Info {
|
||||
node_subnet: state.router.lock().unwrap().node_tun_subnet().to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
impl Serialize for Metric {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
||||
Reference in new issue
Block a user