@@ -40,6 +40,7 @@ const TEXT_ENCODING_PREFIXES: [&str; 5] = [
4040const TEXT_ENCODING_SUFFIXES : [ & str ; 3 ] = [ "+xml" , "+yaml" , "+json" ] ;
4141
4242/// Representation of Lambda response
43+ #[ non_exhaustive]
4344#[ doc( hidden) ]
4445#[ derive( Serialize , Debug ) ]
4546#[ serde( untagged) ]
@@ -70,17 +71,22 @@ impl LambdaResponse {
7071
7172 match request_origin {
7273 #[ cfg( feature = "apigw_rest" ) ]
73- RequestOrigin :: ApiGatewayV1 => LambdaResponse :: ApiGatewayV1 ( ApiGatewayProxyResponse {
74- body,
75- is_base64_encoded,
76- status_code : status_code as i64 ,
74+ RequestOrigin :: ApiGatewayV1 => LambdaResponse :: ApiGatewayV1 ( {
75+ let mut response = ApiGatewayProxyResponse :: default ( ) ;
76+
77+ response. body = body;
78+ response. is_base64_encoded = is_base64_encoded;
79+ response. status_code = status_code as i64 ;
7780 // Explicitly empty, as API gateway v1 will merge "headers" and
7881 // "multi_value_headers" fields together resulting in duplicate response headers.
79- headers : HeaderMap :: new ( ) ,
80- multi_value_headers : headers,
82+ response . headers = HeaderMap :: new ( ) ;
83+ response . multi_value_headers = headers;
8184 // Today, this implementation doesn't provide any additional fields
8285 #[ cfg( feature = "catch-all-fields" ) ]
83- other : Default :: default ( )
86+ {
87+ response. other = Default :: default ( ) ;
88+ }
89+ response
8490 } ) ,
8591 #[ cfg( feature = "apigw_http" ) ]
8692 RequestOrigin :: ApiGatewayV2 => {
@@ -96,51 +102,64 @@ impl LambdaResponse {
96102 . collect ( ) ;
97103 headers. remove ( SET_COOKIE ) ;
98104
99- LambdaResponse :: ApiGatewayV2 ( ApiGatewayV2httpResponse {
100- body,
101- is_base64_encoded,
102- status_code : status_code as i64 ,
103- cookies,
105+ LambdaResponse :: ApiGatewayV2 ( {
106+ let mut response = ApiGatewayV2httpResponse :: default ( ) ;
107+ response. body = body;
108+ response. is_base64_encoded = is_base64_encoded;
109+ response. status_code = status_code as i64 ;
110+ response. cookies = cookies;
104111 // API gateway v2 doesn't have "multi_value_headers" field. Duplicate headers
105112 // are combined with commas and included in the headers field.
106- headers,
107- multi_value_headers : HeaderMap :: new ( ) ,
113+ response . headers = headers ;
114+ response . multi_value_headers = HeaderMap :: new ( ) ;
108115 // Today, this implementation doesn't provide any additional fields
109116 #[ cfg( feature = "catch-all-fields" ) ]
110- other : Default :: default ( ) ,
117+ {
118+ response. other = Default :: default ( ) ;
119+ }
120+ response
111121 } )
112122 }
113123 #[ cfg( feature = "alb" ) ]
114- RequestOrigin :: Alb => LambdaResponse :: Alb ( AlbTargetGroupResponse {
115- body,
116- status_code : status_code as i64 ,
117- is_base64_encoded,
124+ RequestOrigin :: Alb => LambdaResponse :: Alb ( {
125+ let mut response = AlbTargetGroupResponse :: default ( ) ;
126+
127+ response. body = body;
128+ response. is_base64_encoded = is_base64_encoded;
129+ response. status_code = status_code as i64 ;
118130 // ALB responses are used for ALB integration, which can be configured to use
119131 // either "headers" or "multi_value_headers" field. We need to return both fields
120132 // to ensure both configuration work correctly.
121- headers : headers. clone ( ) ,
122- multi_value_headers : headers,
123- status_description : Some ( format ! (
133+ response . headers = headers. clone ( ) ;
134+ response . multi_value_headers = headers;
135+ response . status_description = Some ( format ! (
124136 "{} {}" ,
125137 status_code,
126138 parts. status. canonical_reason( ) . unwrap_or_default( )
127- ) ) ,
139+ ) ) ;
128140 // Today, this implementation doesn't provide any additional fields
129141 #[ cfg( feature = "catch-all-fields" ) ]
130- other : Default :: default ( ) ,
142+ {
143+ response. other = Default :: default ( ) ;
144+ }
145+ response
131146 } ) ,
132147 #[ cfg( feature = "apigw_websockets" ) ]
133- RequestOrigin :: WebSocket => LambdaResponse :: ApiGatewayV1 ( ApiGatewayProxyResponse {
134- body,
135- is_base64_encoded,
136- status_code : status_code as i64 ,
148+ RequestOrigin :: WebSocket => LambdaResponse :: ApiGatewayV1 ( {
149+ let mut response = ApiGatewayProxyResponse :: default ( ) ;
150+ response. body = body;
151+ response. is_base64_encoded = is_base64_encoded;
152+ response. status_code = status_code as i64 ;
137153 // Explicitly empty, as API gateway v1 will merge "headers" and
138154 // "multi_value_headers" fields together resulting in duplicate response headers.
139- headers : HeaderMap :: new ( ) ,
140- multi_value_headers : headers,
155+ response . headers = HeaderMap :: new ( ) ;
156+ response . multi_value_headers = headers;
141157 // Today, this implementation doesn't provide any additional fields
142158 #[ cfg( feature = "catch-all-fields" ) ]
143- other : Default :: default ( ) ,
159+ {
160+ response. other = Default :: default ( ) ;
161+ }
162+ response
144163 } ) ,
145164 #[ cfg( feature = "pass_through" ) ]
146165 RequestOrigin :: PassThrough => {
0 commit comments