File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Examples/ServiceLifecycle Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,17 @@ let package = Package(
1414 dependencies: [
1515 . package ( url: " https://github.com/vapor/postgres-nio.git " , from: " 1.26.0 " ) ,
1616 . package ( url: " https://github.com/swift-server/swift-aws-lambda-runtime.git " , branch: " main " ) ,
17+ . package ( url: " https://github.com/swift-server/swift-aws-lambda-events.git " , from: " 1.0.0 " ) ,
1718 . package ( url: " https://github.com/swift-server/swift-service-lifecycle.git " , from: " 2.6.3 " ) ,
1819 ] ,
1920 targets: [
2021 . executableTarget(
2122 name: " LambdaWithServiceLifecycle " ,
2223 dependencies: [
2324 . product( name: " PostgresNIO " , package : " postgres-nio " ) ,
24- . product( name: " AWSLambdaRuntime " , package : " swift-aws-lambda-runtime " ) ,
2525 . product( name: " ServiceLifecycle " , package : " swift-service-lifecycle " ) ,
26+ . product( name: " AWSLambdaRuntime " , package : " swift-aws-lambda-runtime " ) ,
27+ . product( name: " AWSLambdaEvents " , package : " swift-aws-lambda-events " ) ,
2628 ]
2729 )
2830 ]
Original file line number Diff line number Diff line change 1313//===----------------------------------------------------------------------===//
1414
1515import AWSLambdaRuntime
16+ import AWSLambdaEvents
1617import Logging
1718import PostgresNIO
1819import ServiceLifecycle
@@ -66,7 +67,7 @@ struct LambdaFunction {
6667
6768 /// Function handler. This code is called at each function invocation
6869 /// input event is ignored in this demo.
69- private func handler( event: String , context: LambdaContext ) async -> [ User ] {
70+ private func handler( event: APIGatewayV2Request , context: LambdaContext ) async throws -> APIGatewayV2Response {
7071
7172 var result : [ User ] = [ ]
7273 do {
@@ -89,7 +90,11 @@ struct LambdaFunction {
8990 logger. error ( " Database Error " , metadata: [ " cause " : " \( String ( reflecting: error) ) " ] )
9091 }
9192
92- return result
93+ return try . init(
94+ statusCode: . ok,
95+ headers: [ " content-type " : " application/json " ] ,
96+ encodableBody: result
97+ )
9398 }
9499
95100 /// Prepare the database
You can’t perform that action at this time.
0 commit comments