| 161 | } |
| 162 | |
| 163 | async fn update_question( |
| 164 | id: String, |
| 165 | store: Store, |
| 166 | question: Question, |
| 167 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 168 | match store.questions.write().await.get_mut(&QuestionId(id)) { |
| 169 | Some(q) => *q = question, |
| 170 | None => return Err(warp::reject::custom(Error::QuestionNotFound)), |
| 171 | } |
| 172 | |
| 173 | Ok(warp::reply::with_status("Question updated", StatusCode::OK)) |
| 174 | } |
| 175 | |
| 176 | async fn delete_question(id: String, store: Store) -> Result<impl warp::Reply, warp::Rejection> { |
| 177 | match store.questions.write().await.remove(&QuestionId(id)) { |