Function from_fn
pub fn from_fn<F, T>(f: F) -> FromFnLayer<F, (), T>
Create a middleware from an async function.
from_fn requires the function given to
- Be an
async fn. - Take zero or more
FromRequestPartsextractors. - Take exactly one
FromRequestextractor as the second to last argument. - Take
Nextas the last argument. - Return something that implements
IntoResponse.
Note that this function doesn't support extracting State. For that, use from_fn_with_state.
Example
use ;
async
let app = new
.route
.layer;
# let app: Router = app;
Running extractors
use ;
async
let app = new
.route
.route_layer;
# let app: Router = app;