From ca01676916e58a28a29447827f8461f79c90e2f8 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Fri, 28 Apr 2023 00:08:16 -0500 Subject: [PATCH] Use 404 response code when appropriate --- actix/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/actix/src/main.rs b/actix/src/main.rs index 33b4919..1fbf216 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -2,7 +2,9 @@ use actix_files::{Files, NamedFile}; use actix_session::{storage::CookieSessionStore, Session, SessionMiddleware}; use actix_web::{ cookie::Key, - delete, get, middleware, post, + delete, get, + http::StatusCode, + middleware, post, web::{self, Redirect}, App, HttpResponse, HttpServer, Responder, }; @@ -67,7 +69,7 @@ async fn link_handler(shortlink: web::Path, data: web::Data) - let shortlink_str = shortlink.to_string(); let longlink = utils::get_longurl(shortlink_str, &data.db); if longlink == *"" { - Redirect::to("/err/404") + Redirect::to("/err/404").using_status_code(StatusCode::NOT_FOUND) } else { database::add_hit(shortlink.as_str(), &data.db); Redirect::to(longlink).permanent()