@@ -18,7 +18,11 @@ import OpenAPIRuntime
1818import HTTPTypes
1919
2020/// Specialization of LambdaHandler which runs an OpenAPILambda
21- public struct OpenAPILambdaHandler < L: OpenAPILambda > : LambdaHandler {
21+ public struct OpenAPILambdaHandler < L: OpenAPILambda > : Sendable where L. Event: Sendable , L. Output: Sendable {
22+
23+ private let router : OpenAPILambdaRouter
24+ private let transport : OpenAPILambdaTransport
25+ private let lambda : L
2226
2327 /// the input type for this Lambda handler (received from the `OpenAPILambda`)
2428 public typealias Event = L . Event
@@ -31,7 +35,7 @@ public struct OpenAPILambdaHandler<L: OpenAPILambda>: LambdaHandler {
3135 /// Create application, set it up and create `OpenAPILambda` from application and create responder
3236 /// - Parameters
3337 /// - context: Lambda initialization context
34- public init ( context : LambdaInitializationContext ) throws {
38+ public init ( ) throws {
3539 self . router = TrieRouter ( )
3640 self . transport = OpenAPILambdaTransport ( router: self . router)
3741 self . lambda = try . init( transport: self . transport)
@@ -45,14 +49,14 @@ public struct OpenAPILambdaHandler<L: OpenAPILambda>: LambdaHandler {
4549 /// - context: Runtime ``LambdaContext``.
4650 ///
4751 /// - Returns: A Lambda result ot type `Output`.
48- public func handle ( _ request : Event , context: LambdaContext ) async throws -> Output {
52+ public func handler ( event : L . Event , context: LambdaContext ) async throws -> L . Output {
4953
50- // by default return HTTP 500
54+ // by default returns HTTP 500
5155 var lambdaResponse : OpenAPILambdaResponse = ( HTTPResponse ( status: . internalServerError) , " unknown error " )
5256
5357 do {
5458 // convert Lambda event source to OpenAPILambdaRequest
55- let request = try lambda. request ( context: context, from: request )
59+ let request = try lambda. request ( context: context, from: event )
5660
5761 // route the request to find the handlers and extract the paramaters
5862 let ( handler, parameters) = try await router. route ( method: request. 0 . method, path: request. 0 . path!)
@@ -103,8 +107,28 @@ public struct OpenAPILambdaHandler<L: OpenAPILambda>: LambdaHandler {
103107 // transform the OpenAPILambdaResponse to the Lambda Output
104108 return lambda. output ( from: lambdaResponse)
105109 }
106-
107- let router : OpenAPILambdaRouter
108- let transport : OpenAPILambdaTransport
109- let lambda : L
110110}
111+
112+ // struct Test<L: OpenAPILambda> where L.Event: Sendable, L.Output: Sendable {
113+ // private let router: OpenAPILambdaRouter
114+ // private let transport: OpenAPILambdaTransport
115+ // private let lambda: L
116+ // private let logger: Logger = Logger(label: "test")
117+
118+ // /// the input type for this Lambda handler (received from the `OpenAPILambda`)
119+ // public typealias Event = L.Event
120+
121+ // /// the output type for this Lambda handler (received from the `OpenAPILambda`)
122+ // public typealias Output = L.Output
123+
124+ // /// Function entry point when the runtime environment is created
125+ // private func main() async throws {
126+ // // Instantiate LambdaRuntime with a handler implementing the business logic of the Lambda function
127+ // let lambdaRuntime = LambdaRuntime(logger: logger, body: self.handler)
128+ // try await lambdaRuntime.run()
129+ // }
130+ // private func handler(event: Event, context: LambdaContext) async throws -> Output {
131+ // fatalError()
132+ // }
133+
134+ // }
0 commit comments