87
87
88
88
struct Runtime < C : Service < http:: Uri > = HttpConnector > {
89
89
client : Client < C > ,
90
+ config : Config ,
90
91
}
91
92
92
93
impl < C > Runtime < C >
@@ -96,11 +97,10 @@ where
96
97
C :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
97
98
C :: Response : AsyncRead + AsyncWrite + Connection + Unpin + Send + ' static ,
98
99
{
99
- pub async fn run < F , A , B > (
100
+ async fn run < F , A , B > (
100
101
& self ,
101
102
incoming : impl Stream < Item = Result < http:: Response < hyper:: Body > , Error > > + Send ,
102
103
mut handler : F ,
103
- config : & Config ,
104
104
) -> Result < ( ) , Error >
105
105
where
106
106
F : Service < LambdaEvent < A > > ,
@@ -125,7 +125,7 @@ where
125
125
}
126
126
127
127
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 ) ;
129
129
let request_id = & ctx. request_id . clone ( ) ;
130
130
131
131
let request_span = match & ctx. xray_trace_id {
@@ -254,11 +254,11 @@ where
254
254
trace ! ( "Loading config from env" ) ;
255
255
let config = Config :: from_env ( ) ?;
256
256
let client = Client :: builder ( ) . build ( ) . expect ( "Unable to create a runtime client" ) ;
257
- let runtime = Runtime { client } ;
257
+ let runtime = Runtime { client, config } ;
258
258
259
259
let client = & runtime. client ;
260
260
let incoming = incoming ( client) ;
261
- runtime. run ( incoming, handler, & config ) . await
261
+ runtime. run ( incoming, handler) . await
262
262
}
263
263
264
264
fn type_name_of_val < T > ( _: T ) -> & ' static str {
@@ -522,10 +522,10 @@ mod endpoint_tests {
522
522
}
523
523
let config = crate :: Config :: from_env ( ) . expect ( "Failed to read env vars" ) ;
524
524
525
- let runtime = Runtime { client } ;
525
+ let runtime = Runtime { client, config } ;
526
526
let client = & runtime. client ;
527
527
let incoming = incoming ( client) . take ( 1 ) ;
528
- runtime. run ( incoming, f, & config ) . await ?;
528
+ runtime. run ( incoming, f) . await ?;
529
529
530
530
// shutdown server
531
531
tx. send ( ( ) ) . expect ( "Receiver has been dropped" ) ;
@@ -565,10 +565,10 @@ mod endpoint_tests {
565
565
log_group : "test_log" . to_string ( ) ,
566
566
} ;
567
567
568
- let runtime = Runtime { client } ;
568
+ let runtime = Runtime { client, config } ;
569
569
let client = & runtime. client ;
570
570
let incoming = incoming ( client) . take ( 1 ) ;
571
- runtime. run ( incoming, f, & config ) . await ?;
571
+ runtime. run ( incoming, f) . await ?;
572
572
573
573
match server. await {
574
574
Ok ( _) => Ok ( ( ) ) ,
0 commit comments