@@ -9,7 +9,7 @@ use router::{Router, Match};
9
9
use conduit:: { Method , Handler , Request , Response } ;
10
10
11
11
pub struct RouteBuilder {
12
- routers : HashMap < Method , Router < Box < Handler > > > ,
12
+ routers : HashMap < Method , Router < Box < dyn Handler > > > ,
13
13
}
14
14
15
15
#[ derive( Debug ) ]
@@ -21,7 +21,7 @@ impl RouteBuilder {
21
21
}
22
22
23
23
pub fn recognize < ' a > ( & ' a self , method : & Method , path : & str )
24
- -> Result < Match < & ' a Box < Handler > > ,
24
+ -> Result < Match < & ' a Box < dyn Handler > > ,
25
25
RouterError >
26
26
{
27
27
match self . routers . get ( method) {
@@ -69,14 +69,14 @@ impl RouteBuilder {
69
69
}
70
70
71
71
impl conduit:: Handler for RouteBuilder {
72
- fn call ( & self , request : & mut Request ) -> Result < Response , Box < Error +Send > > {
72
+ fn call ( & self , request : & mut dyn Request ) -> Result < Response , Box < dyn Error +Send > > {
73
73
let m = {
74
74
let method = request. method ( ) ;
75
75
let path = request. path ( ) ;
76
76
77
77
match self . recognize ( & method, path) {
78
78
Ok ( m) => m,
79
- Err ( e) => return Err ( Box :: new ( e) as Box < Error +Send > )
79
+ Err ( e) => return Err ( Box :: new ( e) as Box < dyn Error +Send > )
80
80
}
81
81
} ;
82
82
@@ -103,12 +103,12 @@ pub trait RequestParams<'a> {
103
103
fn params ( self ) -> & ' a router:: Params ;
104
104
}
105
105
106
- pub fn params < ' a > ( req : & ' a Request ) -> & ' a router:: Params {
106
+ pub fn params < ' a > ( req : & ' a dyn Request ) -> & ' a router:: Params {
107
107
req. extensions ( ) . find :: < router:: Params > ( )
108
108
. expect ( "Missing params" )
109
109
}
110
110
111
- impl < ' a > RequestParams < ' a > for & ' a ( Request + ' a ) {
111
+ impl < ' a > RequestParams < ' a > for & ' a ( dyn Request + ' a ) {
112
112
fn params ( self ) -> & ' a router:: Params {
113
113
params ( self )
114
114
}
@@ -153,8 +153,8 @@ mod tests {
153
153
fn query_string < ' a > ( & ' a self ) -> Option < & ' a str > { unimplemented ! ( ) }
154
154
fn remote_addr ( & self ) -> SocketAddr { unimplemented ! ( ) }
155
155
fn content_length ( & self ) -> Option < u64 > { unimplemented ! ( ) }
156
- fn headers < ' a > ( & ' a self ) -> & ' a Headers { unimplemented ! ( ) }
157
- fn body < ' a > ( & ' a mut self ) -> & ' a mut io:: Read { unimplemented ! ( ) }
156
+ fn headers < ' a > ( & ' a self ) -> & ' a dyn Headers { unimplemented ! ( ) }
157
+ fn body < ' a > ( & ' a mut self ) -> & ' a mut dyn io:: Read { unimplemented ! ( ) }
158
158
fn extensions < ' a > ( & ' a self ) -> & ' a Extensions {
159
159
& self . extensions
160
160
}
@@ -201,15 +201,15 @@ mod tests {
201
201
router
202
202
}
203
203
204
- fn test_handler ( req : & mut conduit:: Request ) -> io:: Result < conduit:: Response > {
204
+ fn test_handler ( req : & mut dyn conduit:: Request ) -> io:: Result < conduit:: Response > {
205
205
let mut res = vec ! ( ) ;
206
206
res. push ( req. params ( ) [ "id" ] . clone ( ) ) ;
207
207
res. push ( format ! ( "{:?}" , req. method( ) ) ) ;
208
208
209
209
Ok ( conduit:: Response {
210
210
status : ( 200 , "OK" ) ,
211
211
headers : HashMap :: new ( ) ,
212
- body : Box :: new ( io:: Cursor :: new ( res. connect ( ", " ) . into_bytes ( ) ) )
212
+ body : Box :: new ( io:: Cursor :: new ( res. join ( ", " ) . into_bytes ( ) ) )
213
213
} )
214
214
}
215
215
}
0 commit comments