Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created July 27, 2020 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardoso/e6324000861379344bd12b21a47d91de to your computer and use it in GitHub Desktop.
Save cardoso/e6324000861379344bd12b21a47d91de to your computer and use it in GitHub Desktop.
import AWSLambdaEvents
import AWSLambdaRuntime
import NIO
// MARK: - Run Lambda
Lambda.run(APIGatewayProxyLambda())
// MARK: - Handler, Request and Response
// FIXME: Use proper Event abstractions once added to AWSLambdaRuntime
struct APIGatewayProxyLambda: EventLoopLambdaHandler {
public typealias In = APIGateway.Request
public typealias Out = APIGateway.Response
public func handle(context: Lambda.Context, event: APIGateway.Request) -> EventLoopFuture<APIGateway.Response> {
context.logger.debug("hello, api gateway!")
return context.eventLoop.makeSucceededFuture(APIGateway.Response(statusCode: .ok, body: "Hello, world!"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment