2023-03-10 08:18:11 +01:00
|
|
|
use actix_web::{Error, HttpResponse, http::StatusCode};
|
2022-06-03 17:24:34 +01:00
|
|
|
use askama::Template;
|
|
|
|
|
|
|
|
use crate::args::{Args, ARGS};
|
|
|
|
|
|
|
|
#[derive(Template)]
|
|
|
|
#[template(path = "error.html")]
|
|
|
|
pub struct ErrorTemplate<'a> {
|
2023-03-10 08:18:11 +01:00
|
|
|
pub status_code: StatusCode,
|
2022-06-03 17:24:34 +01:00
|
|
|
pub args: &'a Args,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn not_found() -> Result<HttpResponse, Error> {
|
2023-03-10 08:18:11 +01:00
|
|
|
Ok(HttpResponse::NotFound()
|
2022-06-03 17:24:34 +01:00
|
|
|
.content_type("text/html")
|
2023-03-10 08:18:11 +01:00
|
|
|
.body(ErrorTemplate {
|
|
|
|
status_code: StatusCode::NOT_FOUND,
|
|
|
|
args: &ARGS
|
|
|
|
}.render().unwrap()))
|
2022-06-03 17:24:34 +01:00
|
|
|
}
|