upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/http/mod.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-02 17:33:39 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-02 17:33:39 +0000
commitc07954f44f4c03cc17d4a83b144667cbcbb226cf (patch)
tree5372c59bbffe741de0374f41e4a58be7fb61bdef /src/http/mod.rs
parentaf331ca00da8a3b937c496076f3f7297b3a5283c (diff)
nip11 add icon
Diffstat (limited to 'src/http/mod.rs')
-rw-r--r--src/http/mod.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index c47c374..5cf8dbe 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -32,6 +32,9 @@ const CORS_ALLOW_ORIGIN: &str = "*";
32const CORS_ALLOW_METHODS: &str = "GET, POST"; 32const CORS_ALLOW_METHODS: &str = "GET, POST";
33const CORS_ALLOW_HEADERS: &str = "Content-Type"; 33const CORS_ALLOW_HEADERS: &str = "Content-Type";
34 34
35/// Embedded icon image (Grasp logo)
36const ICON_PNG: &[u8] = include_bytes!("../../static/icon.png");
37
35/// Extract npub and identifier from a repository URL path (no git subpath required) 38/// Extract npub and identifier from a repository URL path (no git subpath required)
36/// 39///
37/// Parses paths like `/<npub>/<identifier>.git` (for repository webpage/404) 40/// Parses paths like `/<npub>/<identifier>.git` (for repository webpage/404)
@@ -359,6 +362,20 @@ impl Service<Request<Incoming>> for HttpService {
359 } 362 }
360 } 363 }
361 364
365 // Serve static icon at /icon.png
366 if path == "/icon.png" {
367 return Box::pin(async move {
368 Ok(
369 add_cors_headers(Response::builder().header("server", "ngit-grasp"))
370 .status(200)
371 .header("content-type", "image/png")
372 .header("cache-control", "public, max-age=86400")
373 .body(Full::new(Bytes::from_static(ICON_PNG)))
374 .unwrap(),
375 )
376 });
377 }
378
362 // Only serve landing page for root path "/", 404 for everything else 379 // Only serve landing page for root path "/", 404 for everything else
363 let config = self.config.clone(); 380 let config = self.config.clone();
364 Box::pin(async move { 381 Box::pin(async move {