From 36171207f04fc10bf6c37eaa9ed6ff7502baada2 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sat, 21 Dec 2024 10:35:57 +0100 Subject: [PATCH 1/3] update APIGateway example with the new APIGatewayResponse initializer --- Examples/APIGateway/Sources/main.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Examples/APIGateway/Sources/main.swift b/Examples/APIGateway/Sources/main.swift index 2d5707d6..2262f899 100644 --- a/Examples/APIGateway/Sources/main.swift +++ b/Examples/APIGateway/Sources/main.swift @@ -31,10 +31,7 @@ let runtime = LambdaRuntime { header["content-type"] = "application/json" // echo the request in the response - let data = try encoder.encode(event) - let response = String(decoding: data, as: Unicode.UTF8.self) - - return APIGatewayV2Response(statusCode: .ok, headers: header, body: response) + return try APIGatewayV2Response(statusCode: .ok, headers: header, encodableBody: event) } try await runtime.run() From 8e89f2784779d8f45ca2051ac37c7ca08331b097 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sat, 21 Dec 2024 11:17:08 +0100 Subject: [PATCH 2/3] remove encoder --- Examples/APIGateway/Sources/main.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/APIGateway/Sources/main.swift b/Examples/APIGateway/Sources/main.swift index 2262f899..8237ffbf 100644 --- a/Examples/APIGateway/Sources/main.swift +++ b/Examples/APIGateway/Sources/main.swift @@ -21,7 +21,6 @@ import FoundationEssentials import Foundation #endif -let encoder = JSONEncoder() let runtime = LambdaRuntime { (event: APIGatewayV2Request, context: LambdaContext) -> APIGatewayV2Response in From 70046383b833f8a344dd34423a41e4497da84d4a Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sat, 21 Dec 2024 11:22:25 +0100 Subject: [PATCH 3/3] remove import --- Examples/APIGateway/Sources/main.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Examples/APIGateway/Sources/main.swift b/Examples/APIGateway/Sources/main.swift index 8237ffbf..f7662d1c 100644 --- a/Examples/APIGateway/Sources/main.swift +++ b/Examples/APIGateway/Sources/main.swift @@ -15,12 +15,6 @@ import AWSLambdaEvents import AWSLambdaRuntime -#if canImport(FoundationEssentials) -import FoundationEssentials -#else -import Foundation -#endif - let runtime = LambdaRuntime { (event: APIGatewayV2Request, context: LambdaContext) -> APIGatewayV2Response in