Module warp::reject [−][src]
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 400 if the `id` is `0`. let route = warp::path::param() .and_then(|id: u32| { if id == 0 { Err(warp::reject()) } else { Ok("something since id is valid") } });
Structs
Rejection |
Rejection of a request by a |
Functions
bad_request |
Rejects a request with |
forbidden |
Rejects a request with |
not_found |
Rejects a request with |
reject |
Rejects a request with a default |
server_error |
Rejects a request with |
Type Definitions
Cause |
Error cause for a rejection. |