Rocket/core/codegen/tests/complete-decorator.rs

29 lines
560 B
Rust
Raw Normal View History

#![feature(plugin, decl_macro)]
#![plugin(rocket_codegen)]
#[macro_use] extern crate rocket;
use rocket::http::{Cookies, RawStr};
use rocket::request::Form;
#[derive(FromForm)]
2016-12-21 08:09:22 +00:00
struct User<'a> {
name: &'a RawStr,
2016-12-21 08:09:22 +00:00
nickname: String,
}
#[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
}
2017-09-10 08:19:38 +00:00
#[test]
fn main() {
let _ = routes![get];
}