From 89bd29dc78de762db56fea08f3e4f5c06fbcadc8 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 5 Apr 2021 09:59:40 +0200 Subject: [PATCH] [closes #2] removed hello world endpoints --- src/hello/controller.rs | 0 src/hello/mod.rs | 21 --------------------- src/hello/tests.rs | 24 ------------------------ src/main.rs | 2 -- 4 files changed, 47 deletions(-) delete mode 100644 src/hello/controller.rs delete mode 100644 src/hello/mod.rs delete mode 100644 src/hello/tests.rs diff --git a/src/hello/controller.rs b/src/hello/controller.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/hello/mod.rs b/src/hello/mod.rs deleted file mode 100644 index 608d234..0000000 --- a/src/hello/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[cfg(test)] -mod tests; - -pub fn routes() -> Vec { - routes![world, hello, name_age] -} - -#[get("/world")] -fn world() -> &'static str { - "Hello, world!" -} - -#[get("/")] -fn hello(name: String) -> String { - format!("Hello, {}", name) -} - -#[get("/world?&")] -fn name_age(name: String, age: u16) -> String { - format!("Hello, {} who is {} years old!", name, age) -} diff --git a/src/hello/tests.rs b/src/hello/tests.rs deleted file mode 100644 index e19264d..0000000 --- a/src/hello/tests.rs +++ /dev/null @@ -1,24 +0,0 @@ -use rocket::http::Status; -use rocket::local::Client; - -fn rocket() -> rocket::Rocket { - rocket::ignite().mount("/", super::routes()) -} - -#[test] -fn test_world() { - let client = Client::new(rocket()).expect("valid rocket instance"); - let mut response = client.get("/world").dispatch(); - - assert_eq!(response.status(), Status::Ok); - assert_eq!(response.body_string(), Some("Hello, world!".into())); -} - -#[test] -fn test_hello() { - let client = Client::new(rocket()).expect("valid rocket instance"); - let mut response = client.get("/thisisaname").dispatch(); - - assert_eq!(response.status(), Status::Ok); - assert_eq!(response.body_string(), Some("Hello, thisisaname".into())); -} diff --git a/src/main.rs b/src/main.rs index 49101f6..9452f9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,12 +6,10 @@ extern crate rocket; // Route modules mod catchers; mod errors; -mod hello; mod ivago; fn rocket() -> rocket::Rocket { rocket::ignite() - .mount("/hello", hello::routes()) .mount("/ivago", ivago::routes()) .register(catchers![catchers::not_found]) }