fej/src/hello/mod.rs

25 lines
427 B
Rust
Raw Normal View History

2021-03-05 23:34:38 +01:00
#[cfg(test)] mod tests;
pub fn routes() -> Vec<rocket::Route> {
routes![
world,
hello,
name_age
]
}
2021-03-05 23:34:38 +01:00
#[get("/world")]
fn world() -> &'static str {
2021-03-05 23:34:38 +01:00
"Hello, world!"
}
#[get("/<name>")]
fn hello(name: String) -> String {
2021-03-05 23:34:38 +01:00
format!("Hello, {}", name)
}
#[get("/world?<name>&<age>")]
fn name_age(name: String, age: u16) -> String {
2021-03-05 23:34:38 +01:00
format!("Hello, {} who is {} years old!", name, age)
}