mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-05-03 07:22:27 +00:00
35e0919ed2
* Add support for resources when packaging using the SwiftPM plugin. * Copy the resources directory to the working directory instead of recreating the directroy structure. * Add resource packaging example. * Use the bundle's url function to locate the file url. * Fix year for soundness check. --------- Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
29 lines
994 B
Swift
29 lines
994 B
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftAWSLambdaRuntime open source project
|
|
//
|
|
// Copyright (c) 2021 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 AWSLambdaRuntime
|
|
import Foundation
|
|
|
|
// in this example we are reading from a bundled resource and responding with the contents
|
|
|
|
@main
|
|
struct MyLambda: SimpleLambdaHandler {
|
|
func handle(_ input: String, context: LambdaContext) async throws -> String {
|
|
guard let fileURL = Bundle.module.url(forResource: "hello", withExtension: "txt") else {
|
|
fatalError("no file url")
|
|
}
|
|
return try String(contentsOf: fileURL)
|
|
}
|
|
}
|