코드 4-36 질문을 삭제하는 경로 핸들러 추가하기
...
async fn delete_question(
id: String,
store: Store
) -> Result<impl warp::Reply, warp::Rejection> {
match store.questions.write().await.remove(&QuestionId(id)) {
Some(_) => {
return Ok(
warp::reply::with_status(
"Question deleted",
StatusCode::OK
)
)
},
None => return Err(warp::reject::custom(Error::QuestionNotFound)),
}
}
...