Function warp::wrap_fn

source · []
pub fn wrap_fn<F, T, U>(func: F) -> WrapFn<F> where
    F: Fn(T) -> U,
    T: Filter,
    U: Filter
Expand description

Function that receives a filter to be combined with pre and after filters

Examples found in repository?
examples/wrapping.rs (line 28)
21
22
23
24
25
26
27
28
29
30
31
async fn main() {
    // Match any request and return hello world!
    let routes = warp::any()
        .map(|| "hello world")
        .boxed()
        .recover(|_err| async { Ok("recovered") })
        // wrap the filter with hello_wrapper
        .with(warp::wrap_fn(hello_wrapper));

    warp::serve(routes).run(([127, 0, 0, 1], 3030)).await;
}