Function rouille::input::plain_text_body[][src]

pub fn plain_text_body(request: &Request) -> Result<String, PlainTextError>

Read plain text data from the body of a request.

Returns an error if the content-type of the request is not text/plain. Only the UTF-8 encoding is supported. You will get an error if the client passed non-UTF8 data.

If the body of the request exceeds 1MB of data, an error is returned to prevent a malicious client from crashing the server. Use the plain_text_body_with_limit function to customize the limit.

Example

fn route_handler(request: &Request) -> Response {
    let text = try_or_400!(rouille::input::plain_text_body(request));
    Response::text(format!("you sent: {}", text))
}