Added docs; started README; started ivago

This commit is contained in:
Jef Roosens 2021-03-11 20:52:30 +01:00
parent 1ff5682fd9
commit ba5d149a60
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
8 changed files with 44 additions and 27 deletions

0
src/hello/controller.rs Normal file
View file

View 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)
}

View file

@ -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]