Skip to content

Commit

Permalink
Impl Default for CompressionBody when possible (#323)
Browse files Browse the repository at this point in the history
* This allows interop with `tonic::transport::Server` and `tonic::transport::server::Router::serve_with_shutdown` which require that the responses implement `Default`.
  • Loading branch information
Ameobea authored Feb 24, 2023
1 parent 255c28e commit f3d8528
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tower-http/src/compression/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ pin_project! {
}
}

impl<B> Default for CompressionBody<B>
where
B: Body + Default,
{
fn default() -> Self {
Self {
inner: BodyInner::Identity {
inner: B::default(),
},
}
}
}

impl<B> CompressionBody<B>
where
B: Body,
Expand Down

0 comments on commit f3d8528

Please sign in to comment.