We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d5cbe03 commit f98896aCopy full SHA for f98896a
ch_03/src/main.rs
@@ -52,17 +52,17 @@ impl Reject for InvalidId {}
52
53
async fn get_questions() -> Result<impl warp::Reply, warp::Rejection> {
54
let question = Question::new(
55
- QuestionId::from_str("1").expect("No id provided"),
+ QuestionId::from_str("A").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.is_empty() {
62
- true => {
+ match question.id.0.parse::<i32>() {
+ Err(_) => {
63
Err(warp::reject::custom(InvalidId))
64
},
65
- false => {
+ Ok(_) => {
66
Ok(warp::reply::json(
67
&question
68
))
0 commit comments