pub fn aggregate() -> impl Filter<Extract = (impl Buf,), Error = Rejection> + Copy
Expand description
Returns a Filter
that matches any request and extracts a Future
of an
aggregated body.
The Buf
may contain multiple, non-contiguous buffers. This can be more
performant (by reducing copies) when receiving large bodies.
§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 warp::{Buf, Filter};
fn full_body(mut body: impl Buf) {
// It could have several non-contiguous slices of memory...
while body.has_remaining() {
println!("slice = {:?}", body.chunk());
let cnt = body.chunk().len();
body.advance(cnt);
}
}
let route = warp::body::content_length_limit(1024 * 32)
.and(warp::body::aggregate())
.map(full_body);