Closed
Description
After SE-0346 lands in Swift 5.7, it’s possible for us to mark Event
and Output
as primary associate types for LambdaHandler
. This can simplify a demo handler from:
@main
struct MyLambda: LambdaHandler {
typealias Event = String
typealias Output = String
init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}
func handle(_ input: String, context: LambdaContext) async throws -> String {
// as an example, respond with the input's reversed
String(input.reversed())
}
}
into
@main
struct MyLambda: LambdaHandler<String, String> {
init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}
func handle(_ input: String, context: LambdaContext) async throws -> String {
// as an example, respond with the input's reversed
String(input.reversed())
}
}