mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-05-03 07:22:27 +00:00
a5ff8e5c00
Add Hummingbird web framework integration example for AWS Lambda **Motivation:** Developers using the Hummingbird web framework need a clear example of how to integrate it with AWS Lambda. The existing examples focus on basic Lambda handlers, but don't demonstrate how to use popular Swift web frameworks like Hummingbird in a serverless context. **Modifications:** Added a complete Hummingbird Lambda example in Examples/Hummingbird/ including Package.swift with Hummingbird Lambda dependencies, main.swift demonstrating router setup with API Gateway V2 integration, SAM template for deployment, and comprehensive README documentation with build, deploy, and usage instructions. **Result:** Developers can now easily create AWS Lambda functions using the Hummingbird web framework, with a working example that shows router configuration, API Gateway integration, and complete deployment workflow using familiar Hummingbird syntax.
28 lines
858 B
Swift
28 lines
858 B
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftAWSLambdaRuntime open source project
|
|
//
|
|
// Copyright (c) 2024 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 HummingbirdLambda
|
|
import Logging
|
|
|
|
typealias AppRequestContext = BasicLambdaRequestContext<APIGatewayV2Request>
|
|
let router = Router(context: AppRequestContext.self)
|
|
|
|
router.get("hello") { _, _ in
|
|
"Hello"
|
|
}
|
|
|
|
let lambda = APIGatewayV2LambdaFunction(router: router)
|
|
try await lambda.runService()
|