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(
14
14
dependencies: [
15
15
. package ( url: " https://github.com/vapor/postgres-nio.git " , from: " 1.26.0 " ) ,
16
16
. 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 " ) ,
17
18
. package ( url: " https://github.com/swift-server/swift-service-lifecycle.git " , from: " 2.6.3 " ) ,
18
19
] ,
19
20
targets: [
20
21
. executableTarget(
21
22
name: " LambdaWithServiceLifecycle " ,
22
23
dependencies: [
23
24
. product( name: " PostgresNIO " , package : " postgres-nio " ) ,
24
- . product( name: " AWSLambdaRuntime " , package : " swift-aws-lambda-runtime " ) ,
25
25
. 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 " ) ,
26
28
]
27
29
)
28
30
]
Original file line number Diff line number Diff line change 13
13
//===----------------------------------------------------------------------===//
14
14
15
15
import AWSLambdaRuntime
16
+ import AWSLambdaEvents
16
17
import Logging
17
18
import PostgresNIO
18
19
import ServiceLifecycle
@@ -66,7 +67,7 @@ struct LambdaFunction {
66
67
67
68
/// Function handler. This code is called at each function invocation
68
69
/// 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 {
70
71
71
72
var result : [ User ] = [ ]
72
73
do {
@@ -89,7 +90,11 @@ struct LambdaFunction {
89
90
logger. error ( " Database Error " , metadata: [ " cause " : " \( String ( reflecting: error) ) " ] )
90
91
}
91
92
92
- return result
93
+ return try . init(
94
+ statusCode: . ok,
95
+ headers: [ " content-type " : " application/json " ] ,
96
+ encodableBody: result
97
+ )
93
98
}
94
99
95
100
/// Prepare the database
You can’t perform that action at this time.
0 commit comments