2018-08-07 02:58:07 +00:00
|
|
|
#![feature(plugin, decl_macro)]
|
2016-10-07 03:38:13 +00:00
|
|
|
#![plugin(rocket_codegen)]
|
|
|
|
|
2018-08-07 02:58:07 +00:00
|
|
|
#[macro_use] extern crate rocket;
|
2016-10-07 03:38:13 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-08-07 02:58:07 +00:00
|
|
|
#[post("/<_name>?<_query>", format = "application/json", data = "<user>", rank = 2)]
|
|
|
|
fn get<'r>(
|
|
|
|
_name: &RawStr,
|
|
|
|
_query: User<'r>,
|
|
|
|
user: Form<'r, User<'r>>,
|
|
|
|
_cookies: Cookies
|
|
|
|
) -> String {
|
|
|
|
format!("{}:{}", user.get().name, user.get().nickname)
|
2016-12-21 08:09:22 +00:00
|
|
|
}
|
2016-10-07 03:38:13 +00:00
|
|
|
|
2017-09-10 08:19:38 +00:00
|
|
|
#[test]
|
2016-10-07 03:38:13 +00:00
|
|
|
fn main() {
|
|
|
|
let _ = routes![get];
|
|
|
|
}
|