Add middleware::from_fn for creating middleware from async fns (#656)

* Add `middleware::from_fn` for creating middleware from async fns

* More trait impls for `Next`

* Make `Next::run` consume `self`

* Use `.router_layer` in example, since middleware returns early

* Actually `Next` probably shouldn't impl `Clone` and `Service`

Has implications for backpressure and stuff

* Simplify `print-request-response` example

* Address review feedback

* add changelog link
This commit is contained in:
David Pedersen
2021-12-27 14:01:26 +01:00
committed by GitHub
parent 3841ef44d5
commit f4716084a7
7 changed files with 277 additions and 22 deletions
+1
View File
@@ -44,5 +44,6 @@
#![cfg_attr(test, allow(clippy::float_cmp))]
pub mod extract;
pub mod middleware;
pub mod response;
pub mod routing;