File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Examples/APIGateway/Sources Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import AWSLambdaEvents
16
16
import AWSLambdaRuntime
17
17
import class Foundation. JSONEncoder
18
18
19
+ let encoder = JSONEncoder ( )
19
20
let runtime = LambdaRuntime {
20
21
( event: APIGatewayV2Request , context: LambdaContext ) -> APIGatewayV2Response in
21
22
@@ -25,8 +26,8 @@ let runtime = LambdaRuntime {
25
26
header [ " content-type " ] = " application/json "
26
27
27
28
// echo the request in the response
28
- let data = try JSONEncoder ( ) . encode ( event)
29
- let response = String ( data : data, encoding : . utf8 )
29
+ let data = try encoder . encode ( event)
30
+ let response = String ( decoding : data, as : Unicode . UTF8 . self )
30
31
31
32
return APIGatewayV2Response ( statusCode: . ok, headers: header, body: response)
32
33
}
You can’t perform that action at this time.
0 commit comments