Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Update APIGateway example with the new APIGatewayResponse initializer #437

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions Examples/APIGateway/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
import AWSLambdaEvents
import AWSLambdaRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

let encoder = JSONEncoder()
let runtime = LambdaRuntime {
(event: APIGatewayV2Request, context: LambdaContext) -> APIGatewayV2Response in

Expand All @@ -31,10 +24,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()
Loading