Function rouille::input::post::get_post_input [] [src]

pub fn get_post_input<T>(request: &Request) -> Result<T, PostError> where T: Decodable

Attempts to decode the POST data received by the request into a struct.

The struct must implement the Decodable trait from rustc_serialize.

An error is returned if a field is missing, if the content type is not POST data, or if a field cannot be parsed.

Example

#[derive(RustcDecodable)]
struct FormData {
    field1: u32,
    field2: String,
}

let data: FormData = rouille::input::get_post_input(&request).unwrap();