@@ -40,6 +40,7 @@ const TEXT_ENCODING_PREFIXES: [&str; 5] = [
40
40
const TEXT_ENCODING_SUFFIXES : [ & str ; 3 ] = [ "+xml" , "+yaml" , "+json" ] ;
41
41
42
42
/// Representation of Lambda response
43
+ #[ non_exhaustive]
43
44
#[ doc( hidden) ]
44
45
#[ derive( Serialize , Debug ) ]
45
46
#[ serde( untagged) ]
@@ -70,17 +71,22 @@ impl LambdaResponse {
70
71
71
72
match request_origin {
72
73
#[ 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 ;
77
80
// Explicitly empty, as API gateway v1 will merge "headers" and
78
81
// "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;
81
84
// Today, this implementation doesn't provide any additional fields
82
85
#[ cfg( feature = "catch-all-fields" ) ]
83
- other : Default :: default ( )
86
+ {
87
+ response. other = Default :: default ( ) ;
88
+ }
89
+ response
84
90
} ) ,
85
91
#[ cfg( feature = "apigw_http" ) ]
86
92
RequestOrigin :: ApiGatewayV2 => {
@@ -96,51 +102,64 @@ impl LambdaResponse {
96
102
. collect ( ) ;
97
103
headers. remove ( SET_COOKIE ) ;
98
104
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;
104
111
// API gateway v2 doesn't have "multi_value_headers" field. Duplicate headers
105
112
// 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 ( ) ;
108
115
// Today, this implementation doesn't provide any additional fields
109
116
#[ cfg( feature = "catch-all-fields" ) ]
110
- other : Default :: default ( ) ,
117
+ {
118
+ response. other = Default :: default ( ) ;
119
+ }
120
+ response
111
121
} )
112
122
}
113
123
#[ 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 ;
118
130
// ALB responses are used for ALB integration, which can be configured to use
119
131
// either "headers" or "multi_value_headers" field. We need to return both fields
120
132
// 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 ! (
124
136
"{} {}" ,
125
137
status_code,
126
138
parts. status. canonical_reason( ) . unwrap_or_default( )
127
- ) ) ,
139
+ ) ) ;
128
140
// Today, this implementation doesn't provide any additional fields
129
141
#[ cfg( feature = "catch-all-fields" ) ]
130
- other : Default :: default ( ) ,
142
+ {
143
+ response. other = Default :: default ( ) ;
144
+ }
145
+ response
131
146
} ) ,
132
147
#[ 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 ;
137
153
// Explicitly empty, as API gateway v1 will merge "headers" and
138
154
// "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;
141
157
// Today, this implementation doesn't provide any additional fields
142
158
#[ cfg( feature = "catch-all-fields" ) ]
143
- other : Default :: default ( ) ,
159
+ {
160
+ response. other = Default :: default ( ) ;
161
+ }
162
+ response
144
163
} ) ,
145
164
#[ cfg( feature = "pass_through" ) ]
146
165
RequestOrigin :: PassThrough => {
0 commit comments