Update to Axum 0.8
This commit is contained in:
parent
975d1ceee2
commit
e355800f98
20 changed files with 1377 additions and 1199 deletions
|
|
@ -4,7 +4,7 @@ use axum::{
|
|||
extract::{ConnectInfo, Extension, FromRef, Request, State},
|
||||
http::StatusCode,
|
||||
middleware::{self, Next},
|
||||
response::{Response, Result},
|
||||
response::Response,
|
||||
routing::{delete, get, post, put},
|
||||
Router,
|
||||
};
|
||||
|
|
@ -55,6 +55,23 @@ impl axum::response::IntoResponse for db::DBError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
enum AppError {
|
||||
#[error("Database error: {0}")]
|
||||
Database(#[from] db::DBError),
|
||||
|
||||
#[error("Template error: {0}")]
|
||||
Render(#[from] rinja::Error),
|
||||
}
|
||||
|
||||
type Result<T> = std::result::Result<T, AppError>;
|
||||
|
||||
impl axum::response::IntoResponse for AppError {
|
||||
fn into_response(self) -> Response {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, "Template error").into_response()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
const TRACING_LEVEL: tracing::Level = tracing::Level::DEBUG;
|
||||
|
||||
|
|
@ -183,8 +200,8 @@ async fn main() {
|
|||
)
|
||||
// Recipes.
|
||||
.route("/recipe/new", get(services::recipe::create))
|
||||
.route("/recipe/edit/:id", get(services::recipe::edit_recipe))
|
||||
.route("/recipe/view/:id", get(services::recipe::view))
|
||||
.route("/recipe/edit/{id}", get(services::recipe::edit_recipe))
|
||||
.route("/recipe/view/{id}", get(services::recipe::view))
|
||||
// User.
|
||||
.route(
|
||||
"/user/edit",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue