false => Ok(QuestionId(id.to_string())),
true => Err(Error::new(ErrorKind::InvalidInput, "No id pro- vided")),
}
}
}
async fn get_questions(store: Store) -> Result<impl Reply, Rejection> {
let question = Question::new(
QuestionId::from_str("1").expect("No id provided"),
"First Question".to_string(),
"Content of question".to_string(),
Some(vec!["faq".to_string()]),
);
match question.id.0.parse::<i32>() {
Err(_) => {
Err(warp::reject::custom(InvalidId))
}
Ok(_) => {
Ok(warp::reply::json(
&question
))
}
}