@@ -5,9 +5,9 @@ use hyper::net;
55
66pub use self :: Action :: { Continue , Halt } ;
77
8- pub type MiddlewareResult < ' a > = Result < Action < Response < ' a , net:: Fresh > ,
9- Response < ' a , net:: Streaming > > ,
10- NickelError < ' a > > ;
8+ pub type MiddlewareResult < ' mw > = Result < Action < Response < ' mw , net:: Fresh > ,
9+ Response < ' mw , net:: Streaming > > ,
10+ NickelError < ' mw > > ;
1111
1212pub enum Action < T =( ) , U =( ) > {
1313 Continue ( T ) ,
@@ -17,13 +17,13 @@ pub enum Action<T=(), U=()> {
1717// the usage of + Send is weird here because what we really want is + Static
1818// but that's not possible as of today. We have to use + Send for now.
1919pub trait Middleware : Send + ' static + Sync {
20- fn invoke < ' a , ' b > ( & ' a self , _req : & mut Request < ' b , ' a , ' b > , res : Response < ' a , net:: Fresh > ) -> MiddlewareResult < ' a > {
20+ fn invoke < ' mw , ' conn > ( & ' mw self , _req : & mut Request < ' mw , ' conn > , res : Response < ' mw , net:: Fresh > ) -> MiddlewareResult < ' mw > {
2121 Ok ( Continue ( res) )
2222 }
2323}
2424
25- impl < T > Middleware for T where T : for < ' r , ' b , ' a > Fn ( & ' r mut Request < ' b , ' a , ' b > , Response < ' a > ) -> MiddlewareResult < ' a > + Send + Sync + ' static {
26- fn invoke < ' a , ' b > ( & ' a self , req : & mut Request < ' b , ' a , ' b > , res : Response < ' a > ) -> MiddlewareResult < ' a > {
25+ impl < T > Middleware for T where T : for < ' r , ' mw , ' conn > Fn ( & ' r mut Request < ' mw , ' conn > , Response < ' mw > ) -> MiddlewareResult < ' mw > + Send + Sync + ' static {
26+ fn invoke < ' mw , ' conn > ( & ' mw self , req : & mut Request < ' mw , ' conn > , res : Response < ' mw > ) -> MiddlewareResult < ' mw > {
2727 ( * self ) ( req, res)
2828 }
2929}
@@ -52,7 +52,7 @@ impl MiddlewareStack {
5252 self . error_handlers . push ( Box :: new ( handler) ) ;
5353 }
5454
55- pub fn invoke < ' a , ' b > ( & ' a self , mut req : Request < ' a , ' a , ' b > , mut res : Response < ' a > ) {
55+ pub fn invoke < ' mw , ' conn > ( & ' mw self , mut req : Request < ' mw , ' conn > , mut res : Response < ' mw > ) {
5656 for handler in self . handlers . iter ( ) {
5757 match handler. invoke ( & mut req, res) {
5858 Ok ( Halt ( res) ) => {
0 commit comments