Implement path extractor (#124)

Fixes #42
This commit is contained in:
Sunli
2021-08-06 10:17:57 +02:00
committed by GitHub
parent 2be79168d8
commit 9fdbd42fba
14 changed files with 871 additions and 66 deletions
@@ -11,7 +11,7 @@
use axum::{
async_trait,
extract::{Extension, Json, UrlParams},
extract::{Extension, Json, Path},
prelude::*,
response::IntoResponse,
AddExtensionLayer,
@@ -56,7 +56,7 @@ async fn main() {
/// are automatically converted into `AppError` which implements `IntoResponse`
/// so it can be returned from handlers directly.
async fn users_show(
UrlParams((user_id,)): UrlParams<(Uuid,)>,
Path(user_id): Path<Uuid>,
Extension(user_repo): Extension<DynUserRepo>,
) -> Result<response::Json<User>, AppError> {
let user = user_repo.find(user_id).await?;