mirror of https://github.com/rwf2/Rocket.git
24 lines
545 B
Rust
24 lines
545 B
Rust
#![feature(plugin)]
|
|
#![plugin(rocket_codegen)]
|
|
|
|
extern crate rocket;
|
|
|
|
#[get("/hello/<name>/<age>")]
|
|
fn hello(name: &str, age: i8) -> String {
|
|
format!("Hello, {} year old named {}!", age, name)
|
|
}
|
|
|
|
#[error(404)]
|
|
fn not_found(req: &rocket::Request) -> String {
|
|
format!("<p>Sorry, but '{}' is not a valid path!</p>
|
|
<p>Try visiting /hello/<name>/<age> instead.</p>",
|
|
req.uri())
|
|
}
|
|
|
|
fn main() {
|
|
rocket::ignite()
|
|
.mount("/", routes![hello])
|
|
.catch(errors![not_found])
|
|
.launch();
|
|
}
|