(
store: Store,
new_question: NewQuestion,
)
| 75 | } |
| 76 | |
| 77 | pub async fn add_question( |
| 78 | store: Store, |
| 79 | new_question: NewQuestion, |
| 80 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 81 | let title = match check_profanity(new_question.title).await { |
| 82 | Ok(res) => res, |
| 83 | Err(e) => return Err(warp::reject::custom(e)), |
| 84 | }; |
| 85 | |
| 86 | let content = match check_profanity(new_question.content).await { |
| 87 | Ok(res) => res, |
| 88 | Err(e) => return Err(warp::reject::custom(e)), |
| 89 | }; |
| 90 | |
| 91 | let question = NewQuestion { |
| 92 | title, |
| 93 | content, |
| 94 | tags: new_question.tags, |
| 95 | }; |
| 96 | |
| 97 | match store.add_question(question).await { |
| 98 | Ok(question) => Ok(warp::reply::json(&question)), |
| 99 | Err(e) => Err(warp::reject::custom(e)), |
| 100 | } |
| 101 | } |
nothing calls this directly
no test coverage detected