Skip to content

Commit d235fb3

Browse files
author
Gayathri Sairamkrishnan
committed
Make ErrorHandlingMiddleware initializer public
1 parent 9ff1b78 commit d235fb3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift

+13-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ import HTTPTypes
4545
/// It should be determined based on the specific needs of each application.
4646
/// Consider the order of execution and dependencies between middlewares.
4747
public struct ErrorHandlingMiddleware: ServerMiddleware {
48+
49+
/// Creates an ErrorHandlingMiddleware
50+
public init() {}
51+
52+
/// Intercepts an outgoing HTTP request and an incoming HTTP Response, and converts errors(if any) that confirms to ``HTTPResponseConvertible`` to an HTTP response.
53+
/// - Parameters:
54+
/// - request: The HTTP request created during the operation.
55+
/// - body: The HTTP request body created during the operation.
56+
/// - metadata: Request metadata
57+
/// - operationID: The OpenAPI operation identifier.
58+
/// - next: A closure that calls the next middleware, or the transport.
59+
/// - Returns: An HTTPResponse and an optional HTTPBody.
4860
public func intercept(
4961
_ request: HTTPTypes.HTTPRequest,
5062
body: OpenAPIRuntime.HTTPBody?,
@@ -66,14 +78,13 @@ public struct ErrorHandlingMiddleware: ServerMiddleware {
6678
}
6779
}
6880

69-
/// A protocol used by ``ErrorHandlingMiddleware`` to map an error to an `HTTPResponse` and ``HTTPBody``.
81+
/// A protocol used by ``ErrorHandlingMiddleware`` to map an error to an ``HTTPResponse`` and ``HTTPBody``.
7082
/// Adopters who wish to convert their application error to an `HTTPResponse` and ``HTTPBody`` should conform the error type to this protocol.
7183
public protocol HTTPResponseConvertible {
7284

7385
/// An HTTP status to return in the response.
7486
var httpStatus: HTTPResponse.Status { get }
7587
/// The HTTP headers of the response.
76-
///
7788
/// This is optional as default values are provided in the extension.
7889
var httpHeaderFields: HTTPTypes.HTTPFields { get }
7990
/// The body of the HTTP response.

0 commit comments

Comments
 (0)