mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-09 19:19:12 +00:00
0c44e44641
This is a breaking change. This commit introduces `RawStr` to forms. In particular, after this commit, the `&str` type no longer implements `FromFormValue`, and so it cannot be used as a field in forms. Instad, the `&RawStr` can be used. The `FormItems` iterator now returns an `(&RawStr, &RawStr)` pair.
27 lines
516 B
Rust
27 lines
516 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: &str,
|
|
query: User<'r>,
|
|
user: Form<'r, User<'r>>,
|
|
cookies: Cookies)
|
|
-> &'static str {
|
|
"hi"
|
|
}
|
|
|
|
fn main() {
|
|
let _ = routes![get];
|
|
}
|