Function map_request
fn map_request<F, T>(f: F) -> MapRequestLayer<F, (), T>
Create a middleware from an async function that transforms a request.
This differs from tower::util::MapRequest in that it allows you to easily run axum-specific
extractors.
Example
use ;
async
async
let app = new
.route
.layer;
# let _: Router = app;
Rejecting the request
The function given to map_request is allowed to also return a Result which can be used to
reject the request and return a response immediately, without calling the remaining
middleware.
Specifically the valid return types are:
Request<B>Result<Request<B>, E> where E: IntoResponse
use ;
async
let app = new
.route
.route_layer;
# let app: Router = app;
Running extractors
use ;
use HashMap;
async
let app = new
.route
.layer;
# let _: Router = app;
Note that to access state you must use either map_request_with_state.