Module warp::reject

source · []
Expand description

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 Filters 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| async move {
        if id == 0 {
            Err(warp::reject::not_found())
        } else {
            Ok("something since id is valid")
        }
    });

Structs

Invalid request header

Invalid query

A content-length header is required

HTTP method not allowed

Missing cookie

Missing request header

The request payload is too large

Rejection of a request by a Filter.

The request’s content-type is not supported

Traits

A marker trait to ensure proper types are used for custom rejections.

Functions

Rejects a request with a custom cause.

Rejects a request with 404 Not Found.

Rejects a request with 404 Not Found.