1212//
1313//===----------------------------------------------------------------------===//
1414
15+ import AWSLambdaEvents
1516import AWSLambdaRuntime
1617import NIO
1718
@@ -23,63 +24,11 @@ Lambda.run(APIGatewayProxyLambda())
2324
2425// FIXME: Use proper Event abstractions once added to AWSLambdaRuntime
2526struct 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
2829
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 > {
3031 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! " ) )
3633 }
3734}
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