2018-06-28 15:55:15 +00:00
|
|
|
#![feature(plugin, decl_macro, proc_macro_non_items)]
|
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)]
|
2018-09-26 08:13:57 +00:00
|
|
|
fn get(
|
2018-08-07 02:58:07 +00:00
|
|
|
_name: &RawStr,
|
2018-09-26 08:13:57 +00:00
|
|
|
_query: User,
|
|
|
|
user: Form<User>,
|
2018-08-07 02:58:07 +00:00
|
|
|
_cookies: Cookies
|
|
|
|
) -> String {
|
2018-09-26 08:13:57 +00:00
|
|
|
format!("{}:{}", user.name, user.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];
|
|
|
|
}
|