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;
|
|
|
|
use rocket::Rocket;
|
|
|
|
|
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 {
|
|
|
|
format!("Hi {}! You age ({}) is kind of funky.", name, age)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2016-08-27 12:10:29 +00:00
|
|
|
Rocket::new("localhost", 8000).mount_and_launch("/", routes![hi, hello]);
|
2016-08-27 04:34:28 +00:00
|
|
|
}
|