From 57de7c66b3ac7b5940648cf978825045864d970e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 5 Mar 2021 20:58:33 +0100 Subject: [PATCH] Moved hello world to own module --- src/hello/controller.rs | 0 src/hello/mod.rs | 1 + src/hello/routes.rs | 4 ++++ src/ivago/controller.rs | 1 + src/ivago/mod.rs | 0 src/ivago/routes.rs | 1 + src/main.rs | 7 ++----- 7 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 src/hello/controller.rs create mode 100644 src/hello/mod.rs create mode 100644 src/hello/routes.rs create mode 100644 src/ivago/controller.rs create mode 100644 src/ivago/mod.rs create mode 100644 src/ivago/routes.rs diff --git a/src/hello/controller.rs b/src/hello/controller.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/hello/mod.rs b/src/hello/mod.rs new file mode 100644 index 0000000..6a664ab --- /dev/null +++ b/src/hello/mod.rs @@ -0,0 +1 @@ +pub mod routes; diff --git a/src/hello/routes.rs b/src/hello/routes.rs new file mode 100644 index 0000000..521b2ed --- /dev/null +++ b/src/hello/routes.rs @@ -0,0 +1,4 @@ +#[get("/world")] +pub fn world() -> &'static str { + "Hello, world!" +} diff --git a/src/ivago/controller.rs b/src/ivago/controller.rs new file mode 100644 index 0000000..0b3b0a3 --- /dev/null +++ b/src/ivago/controller.rs @@ -0,0 +1 @@ +mod ivago.controller; diff --git a/src/ivago/mod.rs b/src/ivago/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/ivago/routes.rs b/src/ivago/routes.rs new file mode 100644 index 0000000..da7e939 --- /dev/null +++ b/src/ivago/routes.rs @@ -0,0 +1 @@ +mod ivago.routes; diff --git a/src/main.rs b/src/main.rs index 745fcec..d149c41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,8 @@ #[macro_use] extern crate rocket; -#[get("/")] -fn index() -> &'static str { - "Hello, world!" -} +mod hello; fn main() { - rocket::ignite().mount("/", routes![index]).launch(); + rocket::ignite().mount("/hello", routes![hello::routes::world]).launch(); }