12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import AWSLambdaEvents
15
16
import AWSLambdaRuntime
16
17
import NIO
17
18
@@ -23,63 +24,11 @@ Lambda.run(APIGatewayProxyLambda())
23
24
24
25
// FIXME: Use proper Event abstractions once added to AWSLambdaRuntime
25
26
struct APIGatewayProxyLambda : EventLoopLambdaHandler {
26
- public typealias In = APIGatewayRequest
27
- public typealias Out = APIGatewayResponse
27
+ public typealias In = APIGateway . V2 . Request
28
+ public typealias Out = APIGateway . V2 . Response
28
29
29
- public func handle( context: Lambda . Context , payload: APIGatewayRequest ) -> EventLoopFuture < APIGatewayResponse > {
30
+ public func handle( context: Lambda . Context , payload: APIGateway . V2 . Request ) -> EventLoopFuture < APIGateway . V2 . Response > {
30
31
context. logger. debug ( " hello, api gateway! " )
31
- return context. eventLoop. makeSucceededFuture ( APIGatewayResponse ( statusCode: 200 ,
32
- headers: nil ,
33
- multiValueHeaders: nil ,
34
- body: " hello, world! " ,
35
- isBase64Encoded: false ) )
32
+ return context. eventLoop. makeSucceededFuture ( APIGateway . V2. Response ( statusCode: . ok, body: " hello, world! " ) )
36
33
}
37
34
}
38
-
39
- struct APIGatewayRequest : Codable {
40
- let resource : String
41
- let path : String
42
- let httpMethod : String ?
43
- let headers : [ String : String ] ?
44
- let multiValueHeaders : [ String : [ String ] ] ?
45
- let queryStringParameters : [ String : String ] ?
46
- let multiValueQueryStringParameters : [ String : [ String ] ] ?
47
- let pathParameters : [ String : String ] ?
48
- let stageVariables : [ String : String ] ?
49
- let requestContext : Context ?
50
- let body : String ?
51
- let isBase64Encoded : Bool ?
52
-
53
- struct Context : Codable {
54
- let accountId : String ?
55
- let resourceId : String ?
56
- let stage : String ?
57
- let requestId : String ?
58
- let identity : Identity ?
59
- let resourcePath : String ?
60
- let httpMethod : String ?
61
- let apiId : String
62
- }
63
-
64
- struct Identity : Codable {
65
- let cognitoIdentityPoolId : String ?
66
- let accountId : String ?
67
- let cognitoIdentityId : String ?
68
- let caller : String ?
69
- let apiKey : String ?
70
- let sourceIp : String ?
71
- let cognitoAuthenticationType : String ?
72
- let cognitoAuthenticationProvider : String ?
73
- let userArn : String ?
74
- let userAgent : String ?
75
- let user : String ?
76
- }
77
- }
78
-
79
- struct APIGatewayResponse : Codable {
80
- let statusCode : Int
81
- let headers : [ String : String ] ?
82
- let multiValueHeaders : [ String : [ String ] ] ?
83
- let body : String ?
84
- let isBase64Encoded : Bool ?
85
- }
0 commit comments