Skip to content

Commit

Permalink
feat(upgrade): allow http upgrades with any body type
Browse files Browse the repository at this point in the history
Allow using `Request<T>`/`Response<T>` for any given T with
`upgrade::on` instead of just restricting it to `hyper::Body`.
  • Loading branch information
luqmana authored and seanmonstar committed Nov 3, 2021
1 parent b5022f3 commit ab469eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,31 +258,31 @@ mod sealed {
fn on_upgrade(self) -> OnUpgrade;
}

impl CanUpgrade for http::Request<crate::Body> {
impl<B> CanUpgrade for http::Request<B> {
fn on_upgrade(mut self) -> OnUpgrade {
self.extensions_mut()
.remove::<OnUpgrade>()
.unwrap_or_else(OnUpgrade::none)
}
}

impl CanUpgrade for &'_ mut http::Request<crate::Body> {
impl<B> CanUpgrade for &'_ mut http::Request<B> {
fn on_upgrade(self) -> OnUpgrade {
self.extensions_mut()
.remove::<OnUpgrade>()
.unwrap_or_else(OnUpgrade::none)
}
}

impl CanUpgrade for http::Response<crate::Body> {
impl<B> CanUpgrade for http::Response<B> {
fn on_upgrade(mut self) -> OnUpgrade {
self.extensions_mut()
.remove::<OnUpgrade>()
.unwrap_or_else(OnUpgrade::none)
}
}

impl CanUpgrade for &'_ mut http::Response<crate::Body> {
impl<B> CanUpgrade for &'_ mut http::Response<B> {
fn on_upgrade(self) -> OnUpgrade {
self.extensions_mut()
.remove::<OnUpgrade>()
Expand Down

0 comments on commit ab469eb

Please sign in to comment.