2016-03-12 18:45:19 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(rocket_macros)]
|
|
|
|
|
|
|
|
extern crate rocket;
|
2016-03-15 03:43:52 +00:00
|
|
|
use rocket::Rocket;
|
2016-03-12 18:45:19 +00:00
|
|
|
|
2016-03-15 03:43:52 +00:00
|
|
|
#[route(GET, path = "/<name>")]
|
|
|
|
fn hello(name: String) -> String {
|
|
|
|
format!("Hello, {}!", name)
|
2016-03-12 18:45:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-15 03:43:52 +00:00
|
|
|
#[route(PUT, path = "/<x>/<y>")]
|
|
|
|
fn bye(x: usize, y: usize) -> String {
|
|
|
|
format!("{} + {} = {}", x, y, x + y)
|
2016-03-12 18:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2016-03-15 03:43:52 +00:00
|
|
|
let rocket = Rocket::new("localhost", 8000);
|
|
|
|
rocket.mount_and_launch("/", routes![hello, bye]);
|
2016-03-12 18:45:19 +00:00
|
|
|
}
|