@@ -154,7 +154,7 @@ public struct ClosureHandler<Event: Decodable, Output>: LambdaHandler {
154
154
155
155
/// Initialize with a closure handler over generic `Input` and `Output` types.
156
156
/// - Parameter body: The handler function written as a closure.
157
- public init ( body: @escaping ( Event , LambdaContext ) async throws -> Output ) where Output: Encodable {
157
+ public init ( body: sending @escaping ( Event , LambdaContext ) async throws -> Output ) where Output: Encodable {
158
158
self . body = body
159
159
}
160
160
@@ -192,8 +192,8 @@ extension LambdaRuntime {
192
192
Encoder: LambdaOutputEncoder ,
193
193
Decoder: LambdaEventDecoder
194
194
> (
195
- encoder: Encoder ,
196
- decoder: Decoder ,
195
+ encoder: sending Encoder,
196
+ decoder: sending Decoder,
197
197
body: sending @escaping ( Event , LambdaContext ) async throws -> Output
198
198
)
199
199
where
@@ -205,21 +205,23 @@ extension LambdaRuntime {
205
205
Encoder
206
206
>
207
207
{
208
- let handler = LambdaCodableAdapter (
208
+ let closureHandler = ClosureHandler ( body: body)
209
+ let streamingAdapter = LambdaHandlerAdapter ( handler: closureHandler)
210
+ let codableWrapper = LambdaCodableAdapter (
209
211
encoder: encoder,
210
212
decoder: decoder,
211
- handler: LambdaHandlerAdapter ( handler : ClosureHandler ( body : body ) )
213
+ handler: streamingAdapter
212
214
)
213
215
214
- self . init ( handler: handler )
216
+ self . init ( handler: codableWrapper )
215
217
}
216
218
217
219
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**, an encoder, and a decoder.
218
220
/// - Parameters:
219
221
/// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type.
220
222
/// - body: The handler in the form of a closure.
221
223
public convenience init < Event: Decodable , Decoder: LambdaEventDecoder > (
222
- decoder: Decoder ,
224
+ decoder: sending Decoder,
223
225
body: sending @escaping ( Event , LambdaContext ) async throws -> Void
224
226
)
225
227
where
0 commit comments