@@ -21,12 +21,14 @@ public struct AWSMiddlewareContext {
21
21
public var logger : Logger
22
22
}
23
23
24
+ /// Function to call next middleware in the chain
25
+ public typealias AWSMiddlewareNextHandler = ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse
24
26
/// Middleware handler, function that takes a request, context and the next function to call
25
- public typealias AWSMiddlewareHandler = @Sendable ( AWSHTTPRequest , AWSMiddlewareContext , _ next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse
27
+ public typealias AWSMiddlewareHandler = @Sendable ( AWSHTTPRequest , AWSMiddlewareContext , _ next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse
26
28
27
29
/// Middleware protocol, with function that takes a request, context and the next function to call
28
30
public protocol AWSMiddlewareProtocol : Sendable {
29
- func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse
31
+ func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse
30
32
}
31
33
32
34
/// Middleware initialized with a middleware handle
@@ -39,7 +41,7 @@ public struct AWSMiddleware: AWSMiddlewareProtocol {
39
41
}
40
42
41
43
@inlinable
42
- public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse {
44
+ public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse {
43
45
try await self . middleware ( request, context, next)
44
46
}
45
47
}
@@ -56,7 +58,7 @@ public struct AWSMiddleware2<M0: AWSMiddlewareProtocol, M1: AWSMiddlewareProtoco
56
58
}
57
59
58
60
@inlinable
59
- public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse {
61
+ public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse {
60
62
try await self . m0. handle ( request, context: context) { request, context in
61
63
try await self . m1. handle ( request, context: context, next: next)
62
64
}
@@ -80,7 +82,7 @@ public struct AWSDynamicMiddlewareStack: AWSMiddlewareProtocol {
80
82
}
81
83
82
84
@inlinable
83
- public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse {
85
+ public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse {
84
86
let iterator = self . stack. makeIterator ( )
85
87
return try await self . run ( request, context: context, iterator: iterator, finally: next)
86
88
}
@@ -90,7 +92,7 @@ public struct AWSDynamicMiddlewareStack: AWSMiddlewareProtocol {
90
92
_ request: AWSHTTPRequest ,
91
93
context: AWSMiddlewareContext ,
92
94
iterator: Stack . Iterator ,
93
- finally: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse
95
+ finally: AWSMiddlewareNextHandler
94
96
) async throws -> AWSHTTPResponse {
95
97
var iterator = iterator
96
98
switch iterator. next ( ) {
@@ -107,7 +109,7 @@ public struct AWSDynamicMiddlewareStack: AWSMiddlewareProtocol {
107
109
public struct PassThruMiddleware : AWSMiddlewareProtocol {
108
110
public init ( ) { }
109
111
110
- public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: ( AWSHTTPRequest , AWSMiddlewareContext ) async throws -> AWSHTTPResponse ) async throws -> AWSHTTPResponse {
112
+ public func handle( _ request: AWSHTTPRequest , context: AWSMiddlewareContext , next: AWSMiddlewareNextHandler ) async throws -> AWSHTTPResponse {
111
113
try await next ( request, context)
112
114
}
113
115
}
0 commit comments