Expand description
Parsing JSON data in the body of a request.
Returns an error if the content-type of the request is not JSON, if the JSON is malformed, or if a field is missing or fails to parse.
§Example
fn route_handler(request: &Request) -> Response {
#[derive(Deserialize)]
struct Json {
field1: String,
field2: i32,
}
let json: Json = try_or_400!(rouille::input::json_input(request));
Response::text(format!("field1's value is {}", json.field1))
}
Enums§
- Error that can happen when parsing the JSON input.
Functions§
- Attempts to parse the request’s body as JSON.