From e3174f21afeaab92924c48fe4fcf870e86d14e83 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 3 Apr 2021 20:47:39 +0200 Subject: [PATCH] [#4] We now properly return error values --- src/ivago/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ivago/mod.rs b/src/ivago/mod.rs index 9cf77dc..386bf36 100644 --- a/src/ivago/mod.rs +++ b/src/ivago/mod.rs @@ -3,6 +3,7 @@ mod controller; mod tests; use chrono::NaiveDate; +use rocket::http::Status; use rocket_contrib::json::Json; pub fn routes() -> Vec { @@ -10,21 +11,20 @@ pub fn routes() -> Vec { } // URL: https://www.ivago.be/nl/particulier/autocomplete/garbage/streets?q=Lange -// TODO make this async -// TODO change this so it can return errors instead of empty json #[get("/search?")] -pub fn search_streets_json(street: String) -> Json> { +pub fn route_search_streets(street: String) -> Result>, Status> { match controller::search_streets(&street) { - Ok(streets) => Json(streets), - Err(err) => Json(Vec::new()), + Ok(streets) => Ok(Json(streets)), + Err(err) => Err(Status::InternalServerError), } } #[get("/?&&&")] pub fn route_get_pickup_times( street: controller::Street, - number: u64, + number: u32, start_date: NaiveDate, end_date: NaiveDate, -) -> Json> { +) -> Result>, Status> { + Err(Status::InternalServerError) }