2016-08-27 04:34:28 +00:00
|
|
|
#![feature(plugin)]
|
2016-09-09 03:38:58 +00:00
|
|
|
#![plugin(rocket_codegen)]
|
2016-08-27 04:34:28 +00:00
|
|
|
|
|
|
|
extern crate rocket;
|
|
|
|
|
2016-10-17 22:14:57 +00:00
|
|
|
#[cfg(test)] mod tests;
|
|
|
|
|
2016-09-04 11:06:28 +00:00
|
|
|
#[get("/hello/<name>/<age>")]
|
2016-08-27 04:34:28 +00:00
|
|
|
fn hello(name: &str, age: i8) -> String {
|
|
|
|
format!("Hello, {} year old named {}!", age, name)
|
|
|
|
}
|
|
|
|
|
2016-09-04 11:06:28 +00:00
|
|
|
#[get("/hello/<name>/<age>", rank = 2)]
|
2016-08-27 04:34:28 +00:00
|
|
|
fn hi(name: &str, age: &str) -> String {
|
2016-09-23 04:10:36 +00:00
|
|
|
format!("Hi {}! Your age ({}) is kind of funky.", name, age)
|
2016-08-27 04:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2016-10-04 02:48:33 +00:00
|
|
|
rocket::ignite().mount("/", routes![hi, hello]).launch();
|
2016-08-27 04:34:28 +00:00
|
|
|
}
|