diff --git a/src/router/link.rs b/src/router/link.rs index 70b5ef0..9c86f8a 100644 --- a/src/router/link.rs +++ b/src/router/link.rs @@ -46,21 +46,16 @@ async fn link( async fn link_delete( axum::extract::Path(id): axum::extract::Path, - State(mut state): State, + State(state): State, ) -> Result, (StatusCode, String)> { - state - .remove_record(&id) + let mut conn = state.pool.acquire().await.unwrap(); + + sqlx::query_file!("queries/records/remove_record.sql", id) + .execute(&mut *conn) .await .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; - { - let mut conn = state.pool.acquire().await.unwrap(); - - sqlx::query_file!("queries/records/remove_record.sql", id) - .execute(&mut *conn) - .await - .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; - } + drop(conn); Ok(Html("".to_string())) }