feat(server): redirect index to project homepage

This commit is contained in:
orhun 2021-07-26 16:05:15 +03:00
parent 338802cc9b
commit 08496cb41b
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 7 additions and 2 deletions

View file

@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2018"
description = "A minimal file upload/pastebin service"
authors = ["Orhun Parmaksız <orhunparmaksiz@gmail.com>"]
homepage = "https://github.com/orhun/rustypaste"
repository = "https://github.com/orhun/rustypaste"
[dependencies]
actix-web = "3.3.2"

View file

@ -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]