Skip to content

Commit

Permalink
Implement middleware for &T: Middleware<_> (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
horazont authored Jan 2, 2025
1 parent 7b66642 commit e170d13
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions poem/src/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ impl<E: Endpoint> Middleware<E> for () {
}
}

impl<E: Endpoint, T: Middleware<E>> Middleware<E> for &T {
type Output = T::Output;

fn transform(&self, ep: E) -> Self::Output {
T::transform(self, ep)
}
}

/// A middleware that combines two middlewares.
pub struct CombineMiddleware<A, B, E> {
a: A,
Expand Down

0 comments on commit e170d13

Please sign in to comment.