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
+4 -4
View File
@@ -61,7 +61,7 @@ mod tests {
#[tokio::test]
async fn hello_world() {
let app = app().into_service();
let app = app();
// `Router` implements `tower::Service<Request<Body>>` so we can
// call it like any tower service, no need to run an HTTP server.
@@ -78,7 +78,7 @@ mod tests {
#[tokio::test]
async fn json() {
let app = app().into_service();
let app = app();
let response = app
.oneshot(
@@ -103,7 +103,7 @@ mod tests {
#[tokio::test]
async fn not_found() {
let app = app().into_service();
let app = app();
let response = app
.oneshot(
@@ -154,7 +154,7 @@ mod tests {
// in multiple request
#[tokio::test]
async fn multiple_request() {
let mut app = app().into_service();
let mut app = app();
let request = Request::builder().uri("/").body(Body::empty()).unwrap();
let response = app.ready().await.unwrap().call(request).await.unwrap();