MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / delete_question

Function delete_question

ch_10/src/routes/question.rs:68–85  ·  view source on GitHub ↗
(
    id: i32,
    session: Session,
    store: Store,
)

Source from the content-addressed store, hash-verified

66}
67
68pub async fn delete_question(
69 id: i32,
70 session: Session,
71 store: Store,
72) -> Result<impl warp::Reply, warp::Rejection> {
73 let account_id = session.account_id;
74 if store.is_question_owner(id, &account_id).await? {
75 match store.delete_question(id, account_id).await {
76 Ok(_) => Ok(warp::reply::with_status(
77 format!("Question {} deleted", id),
78 StatusCode::OK,
79 )),
80 Err(e) => Err(warp::reject::custom(e)),
81 }
82 } else {
83 Err(warp::reject::custom(handle_errors::Error::Unauthorized))
84 }
85}
86
87pub async fn add_question(
88 session: Session,

Callers

nothing calls this directly

Calls 2

is_question_ownerMethod · 0.45
delete_questionMethod · 0.45

Tested by

no test coverage detected