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