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(); }