let res: Vec<Question> = store.questions.values().cloned().collect();
Ok(warp::reply::json(&res))
}
async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> {
if let Some(error) = r.find::<CorsForbidden>() {
Ok(warp::reply::with_status(
error.to_string(),
StatusCode::FORBIDDEN,
))
} else if let Some(InvalidId) = r.find() {
Ok(warp::reply::with_status(
"No valid ID presented".to_string(),
StatusCode::UNPROCESSABLE_ENTITY,
))
} else {
Ok(warp::reply::with_status(
"Route not found".to_string(),
StatusCode::NOT_FOUND,
))
}
}
...