[−][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
InvalidHeader | Invalid request header |
InvalidQuery | Invalid query |
LengthRequired | A content-length header is required |
MethodNotAllowed | HTTP method not allowed |
MissingCookie | Missing cookie |
MissingHeader | Missing request header |
PayloadTooLarge | The request payload is too large |
Rejection | Rejection of a request by a |
UnsupportedMediaType | The request's content-type is not supported |
Functions
custom | Rejects a request with a custom cause. |
not_found | Rejects a request with |