2016-10-07 03:38:13 +00:00
|
|
|
#![feature(plugin, custom_derive)]
|
|
|
|
#![plugin(rocket_codegen)]
|
|
|
|
|
|
|
|
extern crate rocket;
|
|
|
|
|
2017-03-31 06:06:53 +00:00
|
|
|
use rocket::http::{Cookies, RawStr};
|
2016-10-12 07:14:42 +00:00
|
|
|
use rocket::request::Form;
|
2016-10-07 03:38:13 +00:00
|
|
|
|
|
|
|
#[derive(FromForm)]
|
2016-12-21 08:09:22 +00:00
|
|
|
struct User<'a> {
|
2017-03-31 06:06:53 +00:00
|
|
|
name: &'a RawStr,
|
2016-12-21 08:09:22 +00:00
|
|
|
nickname: String,
|
2016-10-07 03:38:13 +00:00
|
|
|
}
|
|
|
|
|
2016-10-12 07:14:42 +00:00
|
|
|
#[post("/<name>?<query>", format = "application/json", data = "<user>", rank = 2)]
|
2016-12-21 08:09:22 +00:00
|
|
|
fn get<'r>(name: &str,
|
|
|
|
query: User<'r>,
|
|
|
|
user: Form<'r, User<'r>>,
|
2017-03-07 09:19:06 +00:00
|
|
|
cookies: Cookies)
|
2016-12-21 08:09:22 +00:00
|
|
|
-> &'static str {
|
|
|
|
"hi"
|
|
|
|
}
|
2016-10-07 03:38:13 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = routes![get];
|
|
|
|
}
|