Error::MissingParameters => write!(f, "Missing parameter"),
Error::QuestionNotFound => write!(f, "Question not found"),
}
}
}
async fn update_question(
id: String,
store: Store,
question: Question,
) -> Result<impl warp::Reply, warp::Rejection> {
match store.questions.write().await.get_mut(&QuestionId(id)) {
Some(q) => *q = question,
None => return Err(warp::reject::custom(Error::QuestionNotFound)),
}
Ok(warp::reply::with_status(
"Question updated",
StatusCode::OK
))
}
...