upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/http/landing.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-20 21:36:09 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-20 21:36:09 +0000
commit89c69eae8e75d2b00794087d9ef74fd4856d0f88 (patch)
tree2a1055d98c6de7ec0b83e857817569b2203aa0e9 /src/http/landing.rs
parent62bcfda39d51a459fbf0a7fa48ee9e2ac8505780 (diff)
replace actix with hyper
Diffstat (limited to 'src/http/landing.rs')
-rw-r--r--src/http/landing.rs35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/http/landing.rs b/src/http/landing.rs
index 976ec50..55ffb26 100644
--- a/src/http/landing.rs
+++ b/src/http/landing.rs
@@ -1,40 +1,15 @@
1/// Landing Page Handler 1/// Landing Page Handler
2/// 2///
3/// Serves the HTML landing page or upgrades to WebSocket for Nostr relay connections. 3/// Generates HTML landing page for the Nostr relay.
4use actix_web::{web, HttpRequest, HttpResponse, Result};
5use nostr_relay_builder::LocalRelay;
6
7use crate::config::Config; 4use crate::config::Config;
8 5
9/// Handle landing page or WebSocket upgrade 6/// Generate the HTML landing page
10pub async fn handle( 7pub fn get_html(config: &Config) -> String {
11 req: HttpRequest, 8 format!(
12 stream: web::Payload,
13 config: web::Data<Config>,
14 relay: web::Data<LocalRelay>,
15) -> Result<HttpResponse> {
16 // Check if this is a WebSocket upgrade request
17 if let Some(upgrade) = req.headers().get("upgrade") {
18 if upgrade
19 .to_str()
20 .unwrap_or("")
21 .eq_ignore_ascii_case("websocket")
22 {
23 // Delegate to WebSocket handler
24 return crate::http::websocket::handle(req, stream, relay).await;
25 }
26 }
27
28 // Otherwise, serve the landing page
29 let html = format!(
30 include_str!("../../templates/landing.html"), 9 include_str!("../../templates/landing.html"),
31 relay_name = config.relay_name, 10 relay_name = config.relay_name,
32 relay_description = config.relay_description, 11 relay_description = config.relay_description,
33 domain = config.domain, 12 domain = config.domain,
34 bind_address = config.bind_address, 13 bind_address = config.bind_address,
35 ); 14 )
36
37 Ok(HttpResponse::Ok()
38 .content_type("text/html; charset=utf-8")
39 .body(html))
40} 15}