Finishing up the MVP

This commit is contained in:
Bad Manners 2025-04-13 23:13:51 -03:00
parent 3619063e68
commit 7f533cc583
25 changed files with 535 additions and 291 deletions

View file

@ -1,8 +1,13 @@
use askama::Template;
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
response::{Html, IntoResponse, Response},
};
#[derive(askama::Template)]
#[template(path = "pages/not_found.html")]
struct NotFoundTemplate;
#[derive(Debug, thiserror::Error)]
pub enum SameyError {
#[error("Integer conversion error: {0}")]
@ -47,7 +52,15 @@ impl IntoResponse for SameyError {
SameyError::Multipart(_) | SameyError::BadRequest(_) => {
(StatusCode::BAD_REQUEST, "Invalid request").into_response()
}
SameyError::NotFound => (StatusCode::NOT_FOUND, "Resource not found").into_response(),
SameyError::NotFound => (
StatusCode::NOT_FOUND,
Html(
NotFoundTemplate {}
.render()
.expect("shouldn't fail to render NotFoundTemplate"),
),
)
.into_response(),
SameyError::Authentication(_) => {
(StatusCode::UNAUTHORIZED, "Not authorized").into_response()
}