Rocket/examples/optional_result/src/main.rs

19 lines
339 B
Rust
Raw Normal View History

#![feature(plugin)]
2016-09-09 03:38:58 +00:00
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::Rocket;
2016-09-04 11:06:28 +00:00
#[get("/users/<name>")]
fn user(name: &str) -> Option<&'static str> {
if name == "Sergio" {
Some("Hello, Sergio!")
} else {
None
}
}
fn main() {
Rocket::new("localhost", 8000).mount_and_launch("/", routes![user]);
}