Add support for querying NIP-05 on /.well-known/nostr.json?name=username
This commit is contained in:
parent
e1306608ef
commit
377da44eed
12 changed files with 278 additions and 101 deletions
|
@ -6,19 +6,24 @@ use warp::{Filter, Rejection, Reply};
|
|||
pub fn routes(context: Context) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||
let cors = warp::cors().allow_any_origin();
|
||||
|
||||
static_files().or(index(context)).with(cors)
|
||||
static_files().or(index(context)).with(&cors)
|
||||
}
|
||||
|
||||
fn index(context: Context) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||
// let real_client_ip = warp::header::optional::<std::net::SocketAddr>("X-Real-IP");
|
||||
let real_client_ip = warp::addr::remote();
|
||||
let cors = warp::cors().allow_any_origin();
|
||||
|
||||
let relay_information_document_path = warp::path::end().and(warp::header::header("Accept").and(with_context(context.clone())).and_then(handler::relay_config)).with(&cors);
|
||||
let nostr_relay_path = warp::path::end().and(warp::ws().and(with_context(context.clone()))
|
||||
.and(real_client_ip)
|
||||
.and_then(handler::ws_handler)
|
||||
.with(&cors));
|
||||
let relay_information_document_path = warp::path::end().and(
|
||||
warp::header::header("Accept")
|
||||
.and(with_context(context.clone()))
|
||||
.and_then(handler::relay_config),
|
||||
);
|
||||
let nostr_relay_path = warp::path::end().and(
|
||||
warp::ws()
|
||||
.and(with_context(context.clone()))
|
||||
.and(real_client_ip)
|
||||
.and_then(handler::ws_handler),
|
||||
);
|
||||
|
||||
relay_information_document_path.or(nostr_relay_path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue