File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -56,16 +56,23 @@ extension OpenAPILambdaService {
56
56
/// try await lambdaRuntime.run()
57
57
///
58
58
/// - Returns: A handler function that can be used with AWS Lambda Runtime
59
- public static func handler ( ) throws -> ( Event , LambdaContext ) async throws -> Output {
60
- try OpenAPILambdaHandler < Self > ( ) . handler
59
+ public static func makeHandler ( ) throws -> OpenAPILambdaHandler < Self > {
60
+ try OpenAPILambdaHandler < Self > ( )
61
61
}
62
62
63
63
/// Start the Lambda Runtime with the Lambda handler function for this OpenAPI Lambda implementation with a custom logger,
64
64
/// when one is given.
65
65
/// - Parameter logger: The logger to use for Lambda runtime logging
66
66
public static func run( logger: Logger ? = nil ) async throws {
67
67
let _logger = logger ?? Logger ( label: " OpenAPILambdaService " )
68
- let lambdaRuntime = LambdaRuntime ( logger: _logger, body: try Self . handler ( ) )
68
+
69
+ let handler = LambdaCodableAdapter (
70
+ encoder: JSONEncoder ( ) ,
71
+ decoder: JSONDecoder ( ) ,
72
+ handler: LambdaHandlerAdapter ( handler: try Self . makeHandler ( ) )
73
+ )
74
+
75
+ let lambdaRuntime = LambdaRuntime ( handler: handler, logger: _logger, )
69
76
try await lambdaRuntime. run ( )
70
77
}
71
78
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import OpenAPIRuntime
18
18
import HTTPTypes
19
19
20
20
/// Specialization of LambdaHandler which runs an OpenAPILambda
21
- public struct OpenAPILambdaHandler < OALS: OpenAPILambdaService > : Sendable {
21
+ public struct OpenAPILambdaHandler < OALS: OpenAPILambdaService > : LambdaHandler {
22
22
23
23
private let router : OpenAPILambdaRouter
24
24
private let transport : OpenAPILambdaTransport
@@ -65,7 +65,7 @@ public struct OpenAPILambdaHandler<OALS: OpenAPILambdaService>: Sendable {
65
65
/// - context: Runtime ``LambdaContext``.
66
66
///
67
67
/// - Returns: A Lambda result ot type `Output`.
68
- public func handler ( event: OALS . Event , context: LambdaContext ) async throws -> OALS . Output {
68
+ public func handle ( _ event: OALS . Event , context: AWSLambdaRuntime . LambdaContext ) async throws -> OALS . Output {
69
69
70
70
// by default returns HTTP 500
71
71
var lambdaResponse : OpenAPILambdaResponse = ( HTTPResponse ( status: . internalServerError) , " unknown error " )
You can’t perform that action at this time.
0 commit comments