Add NIP-11 metadata support

This commit is contained in:
benthecarman
2023-02-21 02:09:01 -06:00
parent 82430fb991
commit 981d225b84
2 changed files with 27 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
use crate::nostr::get_nip11_response;
pub(crate) use crate::nostr::{
try_queue_event, NOSTR_QUEUE, NOSTR_QUEUE_2, NOSTR_QUEUE_3, NOSTR_QUEUE_4, NOSTR_QUEUE_5,
NOSTR_QUEUE_6,
@@ -109,7 +110,14 @@ pub async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
empty_response()
})
.get("/", |_, ctx| {
.get("/", |req, ctx| {
// NIP 11
if req.headers().get("Accept").ok().flatten()
== Some("application/nostr+json".to_string())
{
return Response::from_json(&get_nip11_response())?.with_cors(&cors());
}
// For websocket compatibility
let pair = WebSocketPair::new()?;
let server = pair.server;