Added docs; started README; started ivago
This commit is contained in:
parent
1ff5682fd9
commit
ba5d149a60
8 changed files with 44 additions and 27 deletions
0
src/hello/controller.rs
Normal file
0
src/hello/controller.rs
Normal file
|
|
@ -1,16 +1,24 @@
|
|||
#[cfg(test)] mod tests;
|
||||
|
||||
pub fn routes() -> Vec<rocket::Route> {
|
||||
routes![
|
||||
world,
|
||||
hello,
|
||||
name_age
|
||||
]
|
||||
}
|
||||
|
||||
#[get("/world")]
|
||||
pub fn world() -> &'static str {
|
||||
fn world() -> &'static str {
|
||||
"Hello, world!"
|
||||
}
|
||||
|
||||
#[get("/<name>")]
|
||||
pub fn hello(name: String) -> String {
|
||||
fn hello(name: String) -> String {
|
||||
format!("Hello, {}", name)
|
||||
}
|
||||
|
||||
#[get("/world?<name>&<age>")]
|
||||
pub fn name_age(name: String, age: u16) -> String {
|
||||
fn name_age(name: String, age: u16) -> String {
|
||||
format!("Hello, {} who is {} years old!", name, age)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use rocket::local::Client;
|
|||
use rocket::http::Status;
|
||||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
rocket::ignite().mount("/", routes![super::world, super::hello, super::name_age])
|
||||
rocket::ignite().mount("/", super::routes())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Reference in a new issue