From e498fb38c844f336b88aa265684e51a0a751eacc Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 5 Mar 2021 22:18:55 +0100 Subject: [PATCH] Added arguments test --- src/hello/controller.rs | 0 src/hello/routes.rs | 10 ++++++++++ src/main.rs | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) delete mode 100644 src/hello/controller.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/routes.rs b/src/hello/routes.rs index 521b2ed..c7482e9 100644 --- a/src/hello/routes.rs +++ b/src/hello/routes.rs @@ -2,3 +2,13 @@ pub fn world() -> &'static str { "Hello, world!" } + +#[get("/")] +pub fn hello(name: String) -> String { + format!("Hello, {}", name) +} + +#[get("/world?&")] +pub fn name_age(name: String, age: u16) -> String { + format!("Hello, {} who is {} years old!", name, age) +} diff --git a/src/main.rs b/src/main.rs index d149c41..7f811c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,5 +5,9 @@ mod hello; fn main() { - rocket::ignite().mount("/hello", routes![hello::routes::world]).launch(); + rocket::ignite().mount("/hello", routes![ + hello::routes::world, + hello::routes::hello, + hello::routes::name_age + ]).launch(); }