22 lines
397 B
Rust
22 lines
397 B
Rust
#[cfg(test)]
|
|
mod tests;
|
|
|
|
pub fn routes() -> Vec<rocket::Route> {
|
|
routes![world, hello, name_age]
|
|
}
|
|
|
|
#[get("/world")]
|
|
fn world() -> &'static str {
|
|
"Hello, world!"
|
|
}
|
|
|
|
#[get("/<name>")]
|
|
fn hello(name: String) -> String {
|
|
format!("Hello, {}", name)
|
|
}
|
|
|
|
#[get("/world?<name>&<age>")]
|
|
fn name_age(name: String, age: u16) -> String {
|
|
format!("Hello, {} who is {} years old!", name, age)
|
|
}
|