summaryrefslogtreecommitdiff
path: root/src/handlers/admin.rs
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2025-11-21 16:26:35 +0100
committerWriterV2 <primary-v2@protonmail.com>2025-11-21 16:26:35 +0100
commit74db93c431ebc02b1dc43ec12714007d005a9704 (patch)
treea49b7df0d4f34703222a3a3622c8c6fe4f2b3767 /src/handlers/admin.rs
parent4c73ae9ee6e322fd8cba8d4290a5a86d85651576 (diff)
Update story delete endpoint to use id path to identify story
Diffstat (limited to 'src/handlers/admin.rs')
-rw-r--r--src/handlers/admin.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/handlers/admin.rs b/src/handlers/admin.rs
index 03c933b..b0863af 100644
--- a/src/handlers/admin.rs
+++ b/src/handlers/admin.rs
@@ -3,7 +3,7 @@ use std::io::{BufWriter, Write};
use anyhow::Context;
use axum::body::Bytes;
-use axum::extract::{Multipart, Request, State};
+use axum::extract::{Multipart, Path, Request, State};
use axum::http::{HeaderMap, StatusCode};
use axum::middleware::Next;
use axum::response::{IntoResponse, Response};
@@ -126,20 +126,10 @@ pub async fn upload_story(
pub async fn delete_story(
ctx: Extension<ApiContext>,
- mut multipart: Multipart,
+ Path(story_id): Path<i64>,
) -> Result<impl IntoResponse, AppError> {
- if let Some(field) = multipart.next_field().await? {
- if let Some(label) = field.name() {
- if label == "id" {
- let pid = field.text().await?.parse::<i64>()?;
- Story::delete(&ctx.pool, pid).await?;
- return Ok((StatusCode::NO_CONTENT).into_response());
- }
- return Ok(StatusCode::BAD_REQUEST.into_response());
- }
- return Ok(StatusCode::BAD_REQUEST.into_response());
- }
- Ok(StatusCode::BAD_REQUEST.into_response())
+ Story::delete(&ctx.pool, story_id).await?;
+ Ok((StatusCode::NO_CONTENT).into_response())
}
pub async fn get_stories(ctx: Extension<ApiContext>) -> Result<impl IntoResponse, AppError> {