@@ -325,25 +325,15 @@ where
325
325
}
326
326
}
327
327
328
- use rocket:: futures:: future:: BoxFuture ;
329
-
330
- impl < ' r > Responder < ' r > for GraphQLResponse {
331
- fn respond_to < ' a , ' x > ( self , _req : & ' r Request < ' a > ) -> BoxFuture < ' x , response:: Result < ' r > >
332
- where
333
- ' a : ' x ,
334
- ' r : ' x ,
335
- Self : ' x ,
336
- {
328
+ impl < ' r , ' o : ' r > Responder < ' r , ' o > for GraphQLResponse {
329
+ fn respond_to ( self , _req : & ' r Request < ' _ > ) -> response:: Result < ' o > {
337
330
let GraphQLResponse ( status, body) = self ;
338
331
339
- Box :: pin ( async move {
340
- Ok ( Response :: build ( )
341
- . header ( ContentType :: new ( "application" , "json" ) )
342
- . status ( status)
343
- . sized_body ( Cursor :: new ( body) )
344
- . await
345
- . finalize ( ) )
346
- } )
332
+ Response :: build ( )
333
+ . header ( ContentType :: new ( "application" , "json" ) )
334
+ . status ( status)
335
+ . sized_body ( body. len ( ) , Cursor :: new ( body) )
336
+ . ok ( )
347
337
}
348
338
}
349
339
@@ -528,10 +518,10 @@ mod tests {
528
518
}
529
519
}
530
520
531
- #[ test]
532
- fn test_rocket_integration ( ) {
521
+ #[ tokio :: test]
522
+ async fn test_rocket_integration ( ) {
533
523
let rocket = make_rocket ( ) ;
534
- let client = Client :: new ( rocket) . expect ( "valid rocket" ) ;
524
+ let client = Client :: new ( rocket) . await . expect ( "valid rocket" ) ;
535
525
let integration = TestRocketIntegration { client } ;
536
526
537
527
http_tests:: run_http_test_suite ( & integration) ;
@@ -551,7 +541,7 @@ mod tests {
551
541
552
542
let rocket = make_rocket_without_routes ( )
553
543
. mount ( "/" , routes ! [ post_graphql_assert_operation_name_handler] ) ;
554
- let client = Client :: new ( rocket) . expect ( "valid rocket" ) ;
544
+ let client = Client :: new ( rocket) . await . expect ( "valid rocket" ) ;
555
545
556
546
let resp = client
557
547
. post ( "/" )
@@ -583,14 +573,13 @@ mod tests {
583
573
. expect ( "No content type header from handler" )
584
574
. to_string ( ) ;
585
575
let body = response
586
- . body ( )
587
- . expect ( "No body returned from GraphQL handler" )
588
- . into_string ( )
589
- . await ;
576
+ . body_string ( )
577
+ . await
578
+ . expect ( "No body returned from GraphQL handler" ) ;
590
579
591
580
http_tests:: TestResponse {
592
581
status_code,
593
- body,
582
+ body : Some ( body ) ,
594
583
content_type,
595
584
}
596
585
}
0 commit comments