Change Router::with_state and impl Service for Router<()> (#1552)

* Implement `Service` for `Router<(), B>`

* wip

* wip

* fix some tests

* fix examples

* fix doc tests

* clean up docs

* changelog

* fix

* also call `with_state` when converting `MethodRouter` into a `MakeService`

* suggestions from review
This commit is contained in:
David Pedersen
2022-11-24 14:43:10 +00:00
committed by GitHub
parent fde38f6618
commit 0b26411f39
45 changed files with 576 additions and 738 deletions
+1 -3
View File
@@ -35,9 +35,7 @@ async fn main() {
.with(tracing_subscriber::fmt::layer())
.init();
let router_svc = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.into_service();
let router_svc = Router::new().route("/", get(|| async { "Hello, World!" }));
let service = tower::service_fn(move |req: Request<Body>| {
let router_svc = router_svc.clone();