@@ -122,7 +122,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
122
122
update_xray_trace_id_header ( & mut headers) ;
123
123
if let Some ( cookies) = ag. cookies {
124
124
if let Ok ( header_value) = HeaderValue :: from_str ( & cookies. join ( ";" ) ) {
125
- headers. append ( http:: header:: COOKIE , header_value) ;
125
+ headers. insert ( http:: header:: COOKIE , header_value) ;
126
126
}
127
127
}
128
128
@@ -545,6 +545,42 @@ mod tests {
545
545
) ;
546
546
}
547
547
548
+ #[ test]
549
+ fn deserializes_lambda_function_url_request_events ( ) {
550
+ // from the docs
551
+ // https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html#urls-payloads
552
+ let input = include_str ! ( "../tests/data/lambda_function_url_request.json" ) ;
553
+ let result = from_str ( input) ;
554
+ assert ! (
555
+ result. is_ok( ) ,
556
+ "event was not parsed as expected {:?} given {}" ,
557
+ result,
558
+ input
559
+ ) ;
560
+ let req = result. expect ( "failed to parse request" ) ;
561
+ let cookie_header = req
562
+ . headers ( )
563
+ . get_all ( http:: header:: COOKIE )
564
+ . iter ( )
565
+ . map ( |v| v. to_str ( ) . unwrap ( ) . to_string ( ) )
566
+ . reduce ( |acc, nxt| [ acc, nxt] . join ( ";" ) ) ;
567
+
568
+ assert_eq ! ( req. method( ) , "GET" ) ;
569
+ assert_eq ! (
570
+ req. uri( ) ,
571
+ "https://id.lambda-url.eu-west-2.on.aws/my/path?parameter1=value1¶meter1=value2¶meter2=value"
572
+ ) ;
573
+ assert_eq ! ( cookie_header, Some ( "test=hi" . to_string( ) ) ) ;
574
+
575
+ // Ensure this is an APIGWv2 request (Lambda Function URL requests confirm to API GW v2 Request format)
576
+ let req_context = req. request_context ( ) ;
577
+ assert ! (
578
+ matches!( req_context, RequestContext :: ApiGatewayV2 ( _) ) ,
579
+ "expected ApiGatewayV2 context, got {:?}" ,
580
+ req_context
581
+ ) ;
582
+ }
583
+
548
584
#[ test]
549
585
fn deserializes_alb_request_events ( ) {
550
586
// from the docs
0 commit comments