()
| 51 | impl Reject for InvalidId {} |
| 52 | |
| 53 | async fn get_questions() -> Result<impl Reply, Rejection> { |
| 54 | let question = Question::new( |
| 55 | QuestionId::from_str("1").expect("No id provided"), |
| 56 | "First Question".to_string(), |
| 57 | "Content of question".to_string(), |
| 58 | Some(vec!("faq".to_string())), |
| 59 | ); |
| 60 | |
| 61 | match question.id.0.parse::<i32>() { |
| 62 | Err(_) => { |
| 63 | Err(warp::reject::custom(InvalidId)) |
| 64 | }, |
| 65 | Ok(_) => { |
| 66 | Ok(warp::reply::json( |
| 67 | &question |
| 68 | )) |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> { |
| 74 | if let Some(error) = r.find::<CorsForbidden>() { |
nothing calls this directly
no outgoing calls
no test coverage detected