Expand description
Conditionally dispatch requests to the inner service based on the result of a predicate.
Unlike filter mod in
tower, this let you return a custom response
to user when the request is rejected.
§Example
Router::new()
.route("/get", get(|| async { "get works" }))
.layer(FilterExLayer::new(|request: Request<Body>| {
if let Some(_auth) = request.headers().typed_get::<Authorization<Basic>>() {
// TODO: do something
Ok(request)
} else {
Err(StatusCode::UNAUTHORIZED.into_response())
}
}));
Structs§
- Async
Filter Ex - Conditionally dispatch requests to the inner service based on an asynchronous predicate
- Async
Filter ExLayer - Conditionally dispatch requests to the inner service based on an asynchronous predicate
- Filter
Ex - Conditionally dispatch requests to the inner service based on a predicate.
- Filter
ExLayer - Conditionally dispatch requests to the inner service based on a synchronous predicate.
Traits§
- Async
Predicate - Checks a request asynchronously
- Predicate
- Checks a request synchronously