diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 14:42:26 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 14:42:26 +0000 |
| commit | c9b2e08552642bbdb67255782307abf1e7eb78d0 (patch) | |
| tree | 41d41169ac617fde9bc74dff6e334c5622e60943 /src/http | |
| parent | 6fe9d3280e2d675726c9d5c09538354992049b5d (diff) | |
refactor: fix fmt and clippy
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index 6da027c..c47c374 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs | |||
| @@ -293,19 +293,23 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 293 | if repo_path.exists() { | 293 | if repo_path.exists() { |
| 294 | // Serve repository webpage | 294 | // Serve repository webpage |
| 295 | let html = landing::get_repo_html(&config, &npub, &identifier); | 295 | let html = landing::get_repo_html(&config, &npub, &identifier); |
| 296 | Ok(add_cors_headers(Response::builder().header("server", "ngit-grasp")) | 296 | Ok( |
| 297 | .status(200) | 297 | add_cors_headers(Response::builder().header("server", "ngit-grasp")) |
| 298 | .header("content-type", "text/html; charset=utf-8") | 298 | .status(200) |
| 299 | .body(Full::new(Bytes::from(html))) | 299 | .header("content-type", "text/html; charset=utf-8") |
| 300 | .unwrap()) | 300 | .body(Full::new(Bytes::from(html))) |
| 301 | .unwrap(), | ||
| 302 | ) | ||
| 301 | } else { | 303 | } else { |
| 302 | // Serve 404 page for non-existent repository | 304 | // Serve 404 page for non-existent repository |
| 303 | let html = landing::get_404_html(&config, &npub, &identifier); | 305 | let html = landing::get_404_html(&config, &npub, &identifier); |
| 304 | Ok(add_cors_headers(Response::builder().header("server", "ngit-grasp")) | 306 | Ok( |
| 305 | .status(404) | 307 | add_cors_headers(Response::builder().header("server", "ngit-grasp")) |
| 306 | .header("content-type", "text/html; charset=utf-8") | 308 | .status(404) |
| 307 | .body(Full::new(Bytes::from(html))) | 309 | .header("content-type", "text/html; charset=utf-8") |
| 308 | .unwrap()) | 310 | .body(Full::new(Bytes::from(html))) |
| 311 | .unwrap(), | ||
| 312 | ) | ||
| 309 | } | 313 | } |
| 310 | }); | 314 | }); |
| 311 | } | 315 | } |
| @@ -361,19 +365,23 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 361 | if path == "/" { | 365 | if path == "/" { |
| 362 | // Serve landing page for root | 366 | // Serve landing page for root |
| 363 | let html = landing::get_html(&config); | 367 | let html = landing::get_html(&config); |
| 364 | Ok(add_cors_headers(Response::builder().header("server", "ngit-grasp")) | 368 | Ok( |
| 365 | .status(200) | 369 | add_cors_headers(Response::builder().header("server", "ngit-grasp")) |
| 366 | .header("content-type", "text/html; charset=utf-8") | 370 | .status(200) |
| 367 | .body(Full::new(Bytes::from(html))) | 371 | .header("content-type", "text/html; charset=utf-8") |
| 368 | .unwrap()) | 372 | .body(Full::new(Bytes::from(html))) |
| 373 | .unwrap(), | ||
| 374 | ) | ||
| 369 | } else { | 375 | } else { |
| 370 | // Serve generic 404 for unknown paths | 376 | // Serve generic 404 for unknown paths |
| 371 | let html = landing::get_generic_404_html(&config, &path); | 377 | let html = landing::get_generic_404_html(&config, &path); |
| 372 | Ok(add_cors_headers(Response::builder().header("server", "ngit-grasp")) | 378 | Ok( |
| 373 | .status(404) | 379 | add_cors_headers(Response::builder().header("server", "ngit-grasp")) |
| 374 | .header("content-type", "text/html; charset=utf-8") | 380 | .status(404) |
| 375 | .body(Full::new(Bytes::from(html))) | 381 | .header("content-type", "text/html; charset=utf-8") |
| 376 | .unwrap()) | 382 | .body(Full::new(Bytes::from(html))) |
| 383 | .unwrap(), | ||
| 384 | ) | ||
| 377 | } | 385 | } |
| 378 | }) | 386 | }) |
| 379 | } | 387 | } |