Merge pull request #37 from kehiy/feature/liveconns

add live conns to management api + fixing header value.
This commit is contained in:
Michael Dilger 2025-01-30 10:16:51 +13:00 committed by GitHub
commit 8241b868d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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()),
}
}