mirror of
https://github.com/SinTan1729/chhoto-url
synced 2024-12-26 23:58:35 -06:00
Fixed the 404 error page display
This commit is contained in:
parent
8be3e54861
commit
74f3fddd01
1 changed files with 5 additions and 2 deletions
|
@ -60,7 +60,10 @@ async fn siteurl(session: Session) -> HttpResponse {
|
||||||
// 404 error page
|
// 404 error page
|
||||||
#[get("/err/404")]
|
#[get("/err/404")]
|
||||||
async fn error404() -> impl Responder {
|
async fn error404() -> impl Responder {
|
||||||
NamedFile::open_async("./resources/static/404.html").await
|
NamedFile::open_async("./resources/static/404.html")
|
||||||
|
.await
|
||||||
|
.customize()
|
||||||
|
.with_status(StatusCode::NOT_FOUND)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle a given shortlink
|
// Handle a given shortlink
|
||||||
|
@ -69,7 +72,7 @@ async fn link_handler(shortlink: web::Path<String>, data: web::Data<AppState>) -
|
||||||
let shortlink_str = shortlink.to_string();
|
let shortlink_str = shortlink.to_string();
|
||||||
let longlink = utils::get_longurl(shortlink_str, &data.db);
|
let longlink = utils::get_longurl(shortlink_str, &data.db);
|
||||||
if longlink == *"" {
|
if longlink == *"" {
|
||||||
Redirect::to("/err/404").using_status_code(StatusCode::NOT_FOUND)
|
Redirect::to("/err/404")
|
||||||
} else {
|
} else {
|
||||||
let redirect_method = env::var("redirect_method").unwrap_or("PERMANENT".to_string());
|
let redirect_method = env::var("redirect_method").unwrap_or("PERMANENT".to_string());
|
||||||
database::add_hit(shortlink.as_str(), &data.db);
|
database::add_hit(shortlink.as_str(), &data.db);
|
||||||
|
|
Loading…
Reference in a new issue