mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-16 14:39:07 +00:00
f5ec470a7d
This is a breaking change. The `&str` type no longer implements `FromParam`. The `&RawStr` type should be used in its place.
27 lines
519 B
Rust
27 lines
519 B
Rust
#![feature(plugin, custom_derive)]
|
|
#![plugin(rocket_codegen)]
|
|
|
|
extern crate rocket;
|
|
|
|
use rocket::http::{Cookies, RawStr};
|
|
use rocket::request::Form;
|
|
|
|
#[derive(FromForm)]
|
|
struct User<'a> {
|
|
name: &'a RawStr,
|
|
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)
|
|
-> &'static str {
|
|
"hi"
|
|
}
|
|
|
|
fn main() {
|
|
let _ = routes![get];
|
|
}
|