chore: scaffold axum server with in-memory CRUD, auth stub and tracing

This commit is contained in:
2026-04-19 16:03:04 +03:00
parent 132de93600
commit 90c9b9d6ff
10 changed files with 1756 additions and 13 deletions

33
backend/src/error.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::fmt;
use axum::{http::StatusCode, response::IntoResponse};
use tracing::info;
#[derive(Debug)]
pub enum LoftError {
LoginFail,
FileIdNotFound,
}
impl fmt::Display for LoftError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for LoftError {}
impl IntoResponse for LoftError {
fn into_response(self) -> axum::response::Response {
match self {
Self::LoginFail => {
info!("UNAUTHORIZED");
StatusCode::UNAUTHORIZED.into_response()
}
Self::FileIdNotFound => {
info!("NOT_FOUND");
StatusCode::NOT_FOUND.into_response()
}
}
}
}