From 08496cb41ba27a636644ff8d80c2888d3c77716c Mon Sep 17 00:00:00 2001 From: orhun Date: Mon, 26 Jul 2021 16:05:15 +0300 Subject: [PATCH] feat(server): redirect index to project homepage --- Cargo.toml | 2 ++ src/server.rs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d897d81..1b48a37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ version = "0.1.0" edition = "2018" description = "A minimal file upload/pastebin service" authors = ["Orhun Parmaksız "] +homepage = "https://github.com/orhun/rustypaste" +repository = "https://github.com/orhun/rustypaste" [dependencies] actix-web = "3.3.2" diff --git a/src/server.rs b/src/server.rs index 7a5fe1c..31f413d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -13,7 +13,9 @@ use std::env; /// Shows the landing page. #[get("/")] async fn index() -> impl Responder { - HttpResponse::Ok().body("oops!") + HttpResponse::Found() + .header("Location", env!("CARGO_PKG_HOMEPAGE")) + .finish() } /// Serves a file from the upload directory. @@ -89,7 +91,8 @@ mod tests { let mut app = test::init_service(App::new().service(index)).await; let req = test::TestRequest::with_header("content-type", "text/plain").to_request(); let resp = test::call_service(&mut app, req).await; - assert!(resp.status().is_success()); + assert!(resp.status().is_redirection()); + assert_eq!(http::StatusCode::FOUND, resp.status()); } #[actix_rt::test]