[−][src]Module warp::reject
Rejections
Part of the power of the Filter
system is being able to
reject a request from a filter chain. This allows for filters to be
combined with or
, so that if one side of the chain finds that a request
doesn't fulfill its requirements, the other side can try to process
the request.
Many of the built-in filters
will automatically reject
the request with an appropriate rejection. However, you can also build
new custom Filter
s and still want other routes to be
matchable in the case a predicate doesn't hold.
Example
use warp::Filter; // Filter on `/:id`, but reject with 404 if the `id` is `0`. let route = warp::path::param() .and_then(|id: u32| { if id == 0 { Err(warp::reject::not_found()) } else { Ok("something since id is valid") } });
Structs
Rejection | Rejection of a request by a |
Functions
custom | Rejects a request with a custom cause. |
not_found | Rejects a request with |