Function warp::filters::body::json

source ·
pub fn json<T: DeserializeOwned + Send>() -> impl Filter<Extract = (T,), Error = Rejection> + Copy
Expand description

Returns a Filter that matches any request and extracts a Future of a JSON-decoded body.

§Warning

This does not have a default size limit, it would be wise to use one to prevent a overly large request from using too much memory.

§Example

use std::collections::HashMap;
use warp::Filter;

let route = warp::body::content_length_limit(1024 * 32)
    .and(warp::body::json())
    .map(|simple_map: HashMap<String, String>| {
        "Got a JSON body!"
    });