fej/src/ivago/mod.rs

31 lines
813 B
Rust

mod controller;
#[cfg(test)]
mod tests;
use chrono::NaiveDate;
use rocket_contrib::json::Json;
pub fn routes() -> Vec<rocket::Route> {
routes![route_search_streets,]
}
// 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?<street>")]
pub fn search_streets_json(street: String) -> Json<Vec<controller::Street>> {
match controller::search_streets(&street) {
Ok(streets) => Json(streets),
Err(err) => Json(Vec::new()),
}
}
#[get("/?<street>&<number>&<start_date>&<end_date>")]
pub fn route_get_pickup_times(
street: controller::Street,
number: u64,
start_date: NaiveDate,
end_date: NaiveDate,
) -> Json<Vec<controller::PickupTime>> {
}