(
Path(id): Path<i32>,
State(ctx): State<AppContext>,
Json(params): Json<Params>,
)
| 38 | } |
| 39 | |
| 40 | pub async fn update( |
| 41 | Path(id): Path<i32>, |
| 42 | State(ctx): State<AppContext>, |
| 43 | Json(params): Json<Params>, |
| 44 | ) -> Result<Response> { |
| 45 | let item = load_item(&ctx, id).await?; |
| 46 | let mut item = item.into_active_model(); |
| 47 | params.update(&mut item); |
| 48 | let item = item.update(&ctx.db).await?; |
| 49 | format::json(item) |
| 50 | } |
| 51 | |
| 52 | pub async fn remove(Path(id): Path<i32>, State(ctx): State<AppContext>) -> Result<Response> { |
| 53 | load_item(&ctx, id).await?.delete(&ctx.db).await?; |