File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,6 @@ where
122
122
#[ async_trait]
123
123
impl < State : Clone + Send + Sync + ' static > Endpoint < State > for Box < dyn Endpoint < State > > {
124
124
async fn call ( & self , request : Request < State > ) -> crate :: Result {
125
- self . call ( request) . await
125
+ self . as_ref ( ) . call ( request) . await
126
126
}
127
127
}
Original file line number Diff line number Diff line change
1
+ use tide:: http:: { Method , Request , Url } ;
2
+ use tide:: Response ;
3
+
4
+ #[ async_std:: test]
5
+ async fn should_accept_boxed_endpoints ( ) {
6
+ fn endpoint ( ) -> Box < dyn tide:: Endpoint < ( ) > > {
7
+ Box :: new ( |_| async { Ok ( "hello world" ) } )
8
+ }
9
+
10
+ let mut app = tide:: Server :: new ( ) ;
11
+ app. at ( "/" ) . get ( endpoint ( ) ) ;
12
+
13
+ let mut response: Response = app
14
+ . respond ( Request :: new (
15
+ Method :: Get ,
16
+ Url :: parse ( "http://example.com/" ) . unwrap ( ) ,
17
+ ) )
18
+ . await
19
+ . unwrap ( ) ;
20
+
21
+ assert_eq ! (
22
+ response. take_body( ) . into_string( ) . await . unwrap( ) ,
23
+ "hello world"
24
+ ) ;
25
+ }
You can’t perform that action at this time.
0 commit comments