Skip to content

Commit

Permalink
feat(upgrade): allow http upgrades on with 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 committed Oct 30, 2021
1 parent b5022f3 commit 6a2f4e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/upgrade.rs
Expand Up @@ -258,31 +258,31 @@ mod sealed {
fn on_upgrade(self) -> OnUpgrade;
}

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

impl CanUpgrade for http::Response<crate::Body> {
impl<T> CanUpgrade for http::Response<T> {
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<T> CanUpgrade for &'_ mut http::Response<T> {
fn on_upgrade(self) -> OnUpgrade {
self.extensions_mut()
.remove::<OnUpgrade>()
Expand Down

0 comments on commit 6a2f4e7

Please sign in to comment.