()
| 79 | impl Reject for InvalidId {} |
| 80 | |
| 81 | async fn get_questions() -> Result<impl warp::Reply, warp::Rejection> { |
| 82 | let question = Question::new( |
| 83 | QuestionId::from_str("1").expect("No id provided"), |
| 84 | "First Question".to_string(), |
| 85 | "Content of question".to_string(), |
| 86 | Some(vec!("faq".to_string())), |
| 87 | ); |
| 88 | |
| 89 | match question.id.0.parse::<i32>() { |
| 90 | Err(_) => { |
| 91 | Err(warp::reject::custom(InvalidId)) |
| 92 | }, |
| 93 | Ok(_) => { |
| 94 | Ok(warp::reply::json( |
| 95 | &question |
| 96 | )) |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> { |
| 102 | if let Some(error) = r.find::<CorsForbidden>() { |
nothing calls this directly
no outgoing calls
no test coverage detected