mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Remove axum::prelude (#195)
This commit is contained in:
@@ -11,10 +11,12 @@
|
||||
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{Extension, Json, Path},
|
||||
prelude::*,
|
||||
extract::{Extension, Path},
|
||||
handler::{get, post},
|
||||
response::IntoResponse,
|
||||
AddExtensionLayer,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
AddExtensionLayer, Json,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use http::{Response, StatusCode};
|
||||
@@ -60,7 +62,7 @@ async fn main() {
|
||||
async fn users_show(
|
||||
Path(user_id): Path<Uuid>,
|
||||
Extension(user_repo): Extension<DynUserRepo>,
|
||||
) -> Result<response::Json<User>, AppError> {
|
||||
) -> Result<Json<User>, AppError> {
|
||||
let user = user_repo.find(user_id).await?;
|
||||
|
||||
Ok(user.into())
|
||||
@@ -70,7 +72,7 @@ async fn users_show(
|
||||
async fn users_create(
|
||||
Json(params): Json<CreateUser>,
|
||||
Extension(user_repo): Extension<DynUserRepo>,
|
||||
) -> Result<response::Json<User>, AppError> {
|
||||
) -> Result<Json<User>, AppError> {
|
||||
let user = user_repo.create(params).await?;
|
||||
|
||||
Ok(user.into())
|
||||
@@ -104,7 +106,7 @@ impl IntoResponse for AppError {
|
||||
}
|
||||
};
|
||||
|
||||
let mut response = response::Json(json!({
|
||||
let mut response = Json(json!({
|
||||
"error": error_json,
|
||||
}))
|
||||
.into_response();
|
||||
|
||||
Reference in New Issue
Block a user