2016-03-12 18:45:19 +00:00
|
|
|
#![feature(plugin)]
|
2016-09-09 03:38:58 +00:00
|
|
|
#![plugin(rocket_codegen)]
|
2016-03-12 18:45:19 +00:00
|
|
|
|
|
|
|
extern crate rocket;
|
Something works! A simple hacked-up handler, that is.
At the moment, I simply install the first route I see into the Rocket struct
directly. This is quite terrible. What's worse is that I assume that the Route's
path and handler are static! The handler, actually, does have to be static, but
its response may have whatever (valid) lifetime, though I'm not sure anything
but `static makes sense. I'll think about it.
In any case, the weird `static` restrictions need to be removed, and I need to
think about which lifetimes are safe here. IE: Must all routes be static? Can I
use a closure as a route? (that'd be neat). If so, how do we make that work?
In any case, it's nice to see SOMETHING work. Yay!
2016-03-15 07:41:22 +00:00
|
|
|
|
2016-10-17 22:14:57 +00:00
|
|
|
#[cfg(test)] mod tests;
|
|
|
|
|
2016-09-04 08:05:17 +00:00
|
|
|
#[get("/hello/<name>/<age>")]
|
2017-03-31 07:18:58 +00:00
|
|
|
fn hello(name: String, age: u8) -> String {
|
2016-03-18 03:37:34 +00:00
|
|
|
format!("Hello, {} year old named {}!", age, name)
|
2016-03-17 10:29:55 +00:00
|
|
|
}
|
|
|
|
|
2016-09-07 06:24:20 +00:00
|
|
|
#[get("/hello/<name>")]
|
2017-03-31 07:18:58 +00:00
|
|
|
fn hi(name: String) -> String {
|
2016-09-07 06:24:20 +00:00
|
|
|
name
|
|
|
|
}
|
|
|
|
|
2016-03-12 18:45:19 +00:00
|
|
|
fn main() {
|
2016-12-19 09:57:13 +00:00
|
|
|
rocket::ignite().mount("/", routes![hello, hi]).launch();
|
2016-03-12 18:45:19 +00:00
|
|
|
}
|