8787
8888struct Runtime < C : Service < http:: Uri > = HttpConnector > {
8989 client : Client < C > ,
90+ config : Config ,
9091}
9192
9293impl < C > Runtime < C >
@@ -96,11 +97,10 @@ where
9697 C :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
9798 C :: Response : AsyncRead + AsyncWrite + Connection + Unpin + Send + ' static ,
9899{
99- pub async fn run < F , A , B > (
100+ async fn run < F , A , B > (
100101 & self ,
101102 incoming : impl Stream < Item = Result < http:: Response < hyper:: Body > , Error > > + Send ,
102103 mut handler : F ,
103- config : & Config ,
104104 ) -> Result < ( ) , Error >
105105 where
106106 F : Service < LambdaEvent < A > > ,
@@ -125,7 +125,7 @@ where
125125 }
126126
127127 let ctx: Context = Context :: try_from ( parts. headers ) ?;
128- let ctx: Context = ctx. with_config ( config) ;
128+ let ctx: Context = ctx. with_config ( & self . config ) ;
129129 let request_id = & ctx. request_id . clone ( ) ;
130130
131131 let request_span = match & ctx. xray_trace_id {
@@ -254,11 +254,11 @@ where
254254 trace ! ( "Loading config from env" ) ;
255255 let config = Config :: from_env ( ) ?;
256256 let client = Client :: builder ( ) . build ( ) . expect ( "Unable to create a runtime client" ) ;
257- let runtime = Runtime { client } ;
257+ let runtime = Runtime { client, config } ;
258258
259259 let client = & runtime. client ;
260260 let incoming = incoming ( client) ;
261- runtime. run ( incoming, handler, & config ) . await
261+ runtime. run ( incoming, handler) . await
262262}
263263
264264fn type_name_of_val < T > ( _: T ) -> & ' static str {
@@ -522,10 +522,10 @@ mod endpoint_tests {
522522 }
523523 let config = crate :: Config :: from_env ( ) . expect ( "Failed to read env vars" ) ;
524524
525- let runtime = Runtime { client } ;
525+ let runtime = Runtime { client, config } ;
526526 let client = & runtime. client ;
527527 let incoming = incoming ( client) . take ( 1 ) ;
528- runtime. run ( incoming, f, & config ) . await ?;
528+ runtime. run ( incoming, f) . await ?;
529529
530530 // shutdown server
531531 tx. send ( ( ) ) . expect ( "Receiver has been dropped" ) ;
@@ -565,10 +565,10 @@ mod endpoint_tests {
565565 log_group : "test_log" . to_string ( ) ,
566566 } ;
567567
568- let runtime = Runtime { client } ;
568+ let runtime = Runtime { client, config } ;
569569 let client = & runtime. client ;
570570 let incoming = incoming ( client) . take ( 1 ) ;
571- runtime. run ( incoming, f, & config ) . await ?;
571+ runtime. run ( incoming, f) . await ?;
572572
573573 match server. await {
574574 Ok ( _) => Ok ( ( ) ) ,
0 commit comments