add live conns to managment api + fixing header value.

This commit is contained in:
Kay 2025-01-29 18:13:30 +00:00
parent 2340085832
commit 1ebefba20f

View File

@ -18,7 +18,7 @@ fn respond(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Content-Type", "application/nostr+json")
.header("Content-Type", "application/nostr+json+rpc")
.status(status)
.body(
Full::new(s.into_bytes().into())
@ -105,7 +105,8 @@ pub fn handle_inner(command: Value) -> Result<Option<Value>, Error> {
"listallowedpubkeys",
"listbannedevents",
"listbannedpubkeys",
"supportedmethods"
"supportedmethods",
"liveconnections"
]
}))),
@ -214,6 +215,14 @@ pub fn handle_inner(command: Value) -> Result<Option<Value>, Error> {
"changerelaydescription" => Err(ChorusError::NotImplemented.into()),
"changerelayicon" => Err(ChorusError::NotImplemented.into()),
// System
"liveconnections" => {
let num = &GLOBALS.num_connections;
Ok(Some(json!({
"result": num,
})))
}
_ => Err(ChorusError::NotImplemented.into()),
}
}