Function from_extractor
fn from_extractor<E>() -> FromExtractorLayer<E, ()>
Create a middleware from an extractor.
If the extractor succeeds the value will be discarded and the inner service will be called. If the extractor fails the rejection will be returned and the inner service will not be called.
This can be used to perform validation of requests if the validation doesn't produce any useful output, and run the extractor for several handlers without repeating it in the function signature.
Note that if the extractor consumes the request body, as String or
Bytes does, an empty body will be left in its place. Thus won't be
accessible to subsequent extractors or handlers.
Example
use ;
// An extractor that performs authorization.
;
async
async
let app = new
.route
.route
// The extractor will run before all routes
.route_layer;
# let _: Router = app;