mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
35 lines
1.2 KiB
Swift
35 lines
1.2 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftAWSLambdaRuntime open source project
|
|
//
|
|
// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
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.V2.Request
|
|
public typealias Out = APIGateway.V2.Response
|
|
|
|
public func handle(context: Lambda.Context, event: APIGateway.V2.Request) -> EventLoopFuture<APIGateway.V2.Response> {
|
|
context.logger.debug("hello, api gateway!")
|
|
return context.eventLoop.makeSucceededFuture(APIGateway.V2.Response(statusCode: .ok, body: "hello, world!"))
|
|
}
|
|
}
|