Added arguments test

master
Jef Roosens 2021-03-05 22:18:55 +01:00
parent 57de7c66b3
commit e498fb38c8
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
3 changed files with 15 additions and 1 deletions

View File

@ -2,3 +2,13 @@
pub fn world() -> &'static str { pub fn world() -> &'static str {
"Hello, world!" "Hello, world!"
} }
#[get("/<name>")]
pub fn hello(name: String) -> String {
format!("Hello, {}", name)
}
#[get("/world?<name>&<age>")]
pub fn name_age(name: String, age: u16) -> String {
format!("Hello, {} who is {} years old!", name, age)
}

View File

@ -5,5 +5,9 @@
mod hello; mod hello;
fn main() { 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();
} }