From f3d8528a1bd8d20ad53c9b5786f29017be0b5ba6 Mon Sep 17 00:00:00 2001 From: Casey Primozic Date: Fri, 24 Feb 2023 04:01:48 -0800 Subject: [PATCH] Impl `Default` for `CompressionBody` when possible (#323) * This allows interop with `tonic::transport::Server` and `tonic::transport::server::Router::serve_with_shutdown` which require that the responses implement `Default`. --- tower-http/src/compression/body.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tower-http/src/compression/body.rs b/tower-http/src/compression/body.rs index b737151b..71dad424 100644 --- a/tower-http/src/compression/body.rs +++ b/tower-http/src/compression/body.rs @@ -40,6 +40,19 @@ pin_project! { } } +impl Default for CompressionBody +where + B: Body + Default, +{ + fn default() -> Self { + Self { + inner: BodyInner::Identity { + inner: B::default(), + }, + } + } +} + impl CompressionBody where B: Body,