| 141 | } |
| 142 | |
| 143 | async fn add_question( |
| 144 | store: Store, |
| 145 | new_question: NewQuestion, |
| 146 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 147 | let question = Question { |
| 148 | id: QuestionId(format!("q-{}", store.questions.read().await.len() + 1)), |
| 149 | title: new_question.title, |
| 150 | content: new_question.content, |
| 151 | tags: new_question.tags, |
| 152 | }; |
| 153 | |
| 154 | store |
| 155 | .questions |
| 156 | .write() |
| 157 | .await |
| 158 | .insert(question.id.clone(), question); |
| 159 | |
| 160 | Ok(warp::reply::with_status("Question added", StatusCode::OK)) |
| 161 | } |
| 162 | |
| 163 | async fn update_question( |
| 164 | id: String, |