karton/src/endpoints/errors.rs
Jade 42aceb2a01 Fix error codes, handle bad requests for creation
Fix that invalid UTF-8 or continuing the read mid-character crashes
server thread.
2023-03-10 08:18:11 +01:00

20 lines
517 B
Rust

use actix_web::{Error, HttpResponse, http::StatusCode};
use askama::Template;
use crate::args::{Args, ARGS};
#[derive(Template)]
#[template(path = "error.html")]
pub struct ErrorTemplate<'a> {
pub status_code: StatusCode,
pub args: &'a Args,
}
pub async fn not_found() -> Result<HttpResponse, Error> {
Ok(HttpResponse::NotFound()
.content_type("text/html")
.body(ErrorTemplate {
status_code: StatusCode::NOT_FOUND,
args: &ARGS
}.render().unwrap()))
}