Skip to content

Commit 0a4c77d

Browse files
committed
make swift-format happy
1 parent 0c14afa commit 0a4c77d

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

Sources/OpenAPILambdaHandler.swift

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,54 @@ public struct OpenAPILambdaHandler<L: OpenAPILambda>: LambdaHandler {
4949

5050
// by default return HTTP 500
5151
var lambdaResponse: OpenAPILambdaResponse = (HTTPResponse(status: .internalServerError), "unknown error")
52-
52+
5353
do {
5454
// convert Lambda event source to OpenAPILambdaRequest
5555
let request = try lambda.request(context: context, from: request)
56-
56+
5757
// route the request to find the handlers and extract the paramaters
5858
let (handler, parameters) = try await router.route(method: request.0.method, path: request.0.path!)
59-
59+
6060
// call the request handler (and extract the HTTPRequest and HTTPBody)
6161
let httpRequest = request.0
6262
let httpBody = HTTPBody(stringLiteral: request.1 ?? "")
6363
let response = try await handler(httpRequest, httpBody, ServerRequestMetadata(pathParameters: parameters))
64-
64+
6565
// transform the response to an OpenAPILambdaResponse
6666
let maxPayloadSize = 10 * 1024 * 1024 // APIGateway payload is 10M max
6767
let body: String? = try? await String(collecting: response.1 ?? "", upTo: maxPayloadSize)
6868
lambdaResponse = (response.0, body)
69-
70-
} catch OpenAPILambdaRouterError.noHandlerForPath(let path) {
71-
69+
70+
}
71+
catch OpenAPILambdaRouterError.noHandlerForPath(let path) {
72+
7273
// There is no hadler registered for this path. This is a programming error.
73-
lambdaResponse = (HTTPResponse(status: .internalServerError), "There is no OpenAPI handler registered for the path \(path)")
74+
lambdaResponse = (
75+
HTTPResponse(status: .internalServerError),
76+
"There is no OpenAPI handler registered for the path \(path)"
77+
)
78+
79+
}
80+
catch OpenAPILambdaRouterError.noRouteForMethod(let method) {
7481

75-
} catch OpenAPILambdaRouterError.noRouteForMethod(let method) {
76-
7782
// There is no hadler registered for this path. This is a programming error.
7883
lambdaResponse = (HTTPResponse(status: .notFound), "There is no route registered for the method \(method)")
7984

80-
} catch OpenAPILambdaRouterError.noRouteForPath(let path) {
81-
85+
}
86+
catch OpenAPILambdaRouterError.noRouteForPath(let path) {
87+
8288
// There is no hadler registered for this path. This is a programming error.
8389
lambdaResponse = (HTTPResponse(status: .notFound), "There is no route registered for the path \(path)")
8490

85-
} catch OpenAPILambdaHttpError.invalidMethod(let method) {
86-
91+
}
92+
catch OpenAPILambdaHttpError.invalidMethod(let method) {
93+
8794
// the APIGateway HTTP verb is rejected by HTTTypes HTTPRequest.Method => HTTP 500
8895
// this should never happen
89-
lambdaResponse = (HTTPResponse(status: .internalServerError), "Type mismatch between APIGatewayV2 and HTTPRequest.Method. \(method) verb is rejected by HTTPRequest.Method 🤷‍♂️")
96+
lambdaResponse = (
97+
HTTPResponse(status: .internalServerError),
98+
"Type mismatch between APIGatewayV2 and HTTPRequest.Method. \(method) verb is rejected by HTTPRequest.Method 🤷‍♂️"
99+
)
90100

91101
}
92102

0 commit comments

Comments
 (0)