summaryrefslogtreecommitdiff
path: root/src/handlers/admin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/handlers/admin.rs')
-rw-r--r--src/handlers/admin.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/handlers/admin.rs b/src/handlers/admin.rs
index 7c016dd..3d16b32 100644
--- a/src/handlers/admin.rs
+++ b/src/handlers/admin.rs
@@ -132,3 +132,21 @@ pub async fn upload_story(
.await?;
Ok((StatusCode::CREATED, Json(story)).into_response())
}
+
+pub async fn delete_story(
+ ctx: Extension<ApiContext>,
+ mut multipart: Multipart,
+) -> 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())
+}