mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-09 00:00:12 +02:00
+3
-6
@@ -14,7 +14,7 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
extract::{Extension, Json, Query, UrlParams},
|
||||
extract::{Extension, Json, Path, Query},
|
||||
prelude::*,
|
||||
response::IntoResponse,
|
||||
service::ServiceExt,
|
||||
@@ -129,7 +129,7 @@ struct UpdateTodo {
|
||||
}
|
||||
|
||||
async fn todos_update(
|
||||
UrlParams((id,)): UrlParams<(Uuid,)>,
|
||||
Path(id): Path<Uuid>,
|
||||
Json(input): Json<UpdateTodo>,
|
||||
Extension(db): Extension<Db>,
|
||||
) -> Result<impl IntoResponse, StatusCode> {
|
||||
@@ -153,10 +153,7 @@ async fn todos_update(
|
||||
Ok(response::Json(todo))
|
||||
}
|
||||
|
||||
async fn todos_delete(
|
||||
UrlParams((id,)): UrlParams<(Uuid,)>,
|
||||
Extension(db): Extension<Db>,
|
||||
) -> impl IntoResponse {
|
||||
async fn todos_delete(Path(id): Path<Uuid>, Extension(db): Extension<Db>) -> impl IntoResponse {
|
||||
if db.write().unwrap().remove(&id).is_some() {
|
||||
StatusCode::NO_CONTENT
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user