From 25eaf777139d78ed59bf35c4b0f163032ea4311d Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 6 Mar 2021 00:25:40 +0100 Subject: [PATCH] Started search functionality --- src/ivago/mod.rs | 22 ++++++++++++++++++++++ src/ivago/tests.rs | 1 - src/main.rs | 22 +++++++++++++++++----- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/ivago/mod.rs b/src/ivago/mod.rs index e69de29..12d8ed0 100644 --- a/src/ivago/mod.rs +++ b/src/ivago/mod.rs @@ -0,0 +1,22 @@ +#[cfg(test)] mod tests; + +// use rocket_contrib::json::Json; +// use rocket::Route; +use http::{Request, Response}; + + +pub fn routes() -> Vec { + routes![search_streets] +} + +// URL: https://www.ivago.be/nl/particulier/autocomplete/garbage/streets?q=Lange +#[get("/search?")] +pub fn search_streets(street: String) -> String { + // Build the request + let mut request = Request::get( + "https://www.ivago.be/nl/particulier/autocomplete/garbage/streets") + .body(()) + .unwrap(); + + let response = send(request.body(()).unwrap()); +} diff --git a/src/ivago/tests.rs b/src/ivago/tests.rs index da7e939..e69de29 100644 --- a/src/ivago/tests.rs +++ b/src/ivago/tests.rs @@ -1 +0,0 @@ -mod ivago.routes; diff --git a/src/main.rs b/src/main.rs index a4ce2c9..b9623f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,23 @@ #[macro_use] extern crate rocket; mod hello; +mod ivago; + +fn rocket() -> rocket::Rocket { + rocket::ignite() + .mount( + "/hello", + routes![ + hello::world, + hello::hello, + hello::name_age + ] + ).mount( + "/ivago", + ivago::routes() + ) +} fn main() { - rocket::ignite().mount("/hello", routes![ - hello::world, - hello::hello, - hello::name_age - ]).launch(); + rocket().launch(); }