docs(server): add server example using tower::make::Shared (#2440)

`tower` 0.4.5 introduced `Shared` which is a `MakeService` that produces
services by cloning an inner service. This works quite well with `hyper`
if your service doesn't need the incoming connection and implements
`Clone`.

However that might not be entirely obvious so I thought it made sense to
add an example to the docs.

I wasn't quite sure if the example should go in the server or service
module docs but since there already is an example using
`make_service_fn` in the server docs I opted to add it there. Let me
know if you'd rather have it somewhere else.
This commit is contained in:
David Pedersen
2021-02-19 22:50:43 +01:00
committed by GitHub
parent f01de8e503
commit 6efc1a1cce
2 changed files with 36 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ tokio = { version = "1", features = [
] }
tokio-test = "0.4"
tokio-util = { version = "0.6", features = ["codec"] }
tower = { version = "0.4", features = ["make"] }
tower-util = "0.3"
url = "2.2"