Remove buffer from BoxRoute (#270)

Boxing a service normally means using `tower::util::BoxService`. That
doesn't implement `Clone` however so normally I had been combining it
with `Buffer` to get that.

But recently I discovered https://github.com/dtolnay/dyn-clone which
makes it possible to clone trait objects. So this adds a new internal
utility called `CloneBoxService` which replaces the previous
`BoxService` + `Buffer` combo in `BoxRoute`.

I'll investigate upstreaming that to tower. I think it makes sense there
since box + clone is quite a common need.
This commit is contained in:
David Pedersen
2021-08-26 06:34:53 +00:00
committed by GitHub
parent 20f6c3b509
commit 552d69e5d4
7 changed files with 96 additions and 219 deletions
+2
View File
@@ -41,6 +41,8 @@ tower-layer = "0.3"
tower-http = { version = "0.1", features = ["add-extension", "map-response-body"] }
sync_wrapper = "0.1.1"
dyn-clone = "1.0"
# optional dependencies
tokio-tungstenite = { optional = true, version = "0.15" }
sha-1 = { optional = true, version = "0.9.6" }