Skip to content

Commit c3f0340

Browse files
committed
swift format
1 parent b280455 commit c3f0340

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

Sources/AWSLambdaRuntime/Lambda+LocalServer.swift

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ internal struct LambdaHTTPServer {
274274

275275
case .end:
276276
precondition(requestHead != nil, "Received .end without .head")
277-
277+
278278
// process the buffered response for non streaming requests
279279
if !self.isStreamingResponse(requestHead) {
280280
// process the request and send the response
@@ -288,7 +288,7 @@ internal struct LambdaHTTPServer {
288288
await self.responsePool.push(
289289
LocalServerResponse(id: requestId, final: true)
290290
)
291-
291+
292292
}
293293

294294
requestHead = nil
@@ -311,16 +311,15 @@ internal struct LambdaHTTPServer {
311311
/// This function checks if the request is a streaming response request
312312
/// verb = POST, uri = :requestID/response, HTTP Header contains "Transfer-Encoding: chunked"
313313
private func isStreamingResponse(_ requestHead: HTTPRequestHead) -> Bool {
314-
requestHead.method == .POST &&
315-
requestHead.uri.hasSuffix(Consts.postResponseURLSuffix) &&
316-
requestHead.headers.contains(name: "Transfer-Encoding") &&
317-
requestHead.headers["Transfer-Encoding"].contains("chunked")
314+
requestHead.method == .POST && requestHead.uri.hasSuffix(Consts.postResponseURLSuffix)
315+
&& requestHead.headers.contains(name: "Transfer-Encoding")
316+
&& requestHead.headers["Transfer-Encoding"].contains("chunked")
318317
}
319318

320319
/// This function pareses and returns the requestId or nil if the request is malformed
321320
private func getRequestId(from head: HTTPRequestHead) -> String? {
322-
let parts = head.uri.split(separator: "/")
323-
return parts.count > 2 ? String(parts[parts.count - 2]) : nil
321+
let parts = head.uri.split(separator: "/")
322+
return parts.count > 2 ? String(parts[parts.count - 2]) : nil
324323
}
325324
/// This function process the URI request sent by the client and by the Lambda function
326325
///
@@ -378,7 +377,7 @@ internal struct LambdaHTTPServer {
378377
try await self.sendResponse(response, outbound: outbound, logger: logger)
379378
if response.final == true {
380379
logger.trace("/invoke returning")
381-
return // if the response is final, we can return and close the connection
380+
return // if the response is final, we can return and close the connection
382381
}
383382
} else {
384383
logger.error(
@@ -497,7 +496,7 @@ internal struct LambdaHTTPServer {
497496
if response.final {
498497
logger.trace("Sending end")
499498
try await outbound.write(HTTPServerResponsePart.end(nil))
500-
}
499+
}
501500
}
502501

503502
/// A shared data structure to store the current invocation or response requests and the continuation objects.
@@ -585,7 +584,13 @@ internal struct LambdaHTTPServer {
585584
let headers: HTTPHeaders?
586585
let body: ByteBuffer?
587586
let final: Bool
588-
init(id: String? = nil, status: HTTPResponseStatus? = nil, headers: HTTPHeaders? = nil, body: ByteBuffer? = nil, final: Bool = false) {
587+
init(
588+
id: String? = nil,
589+
status: HTTPResponseStatus? = nil,
590+
headers: HTTPHeaders? = nil,
591+
body: ByteBuffer? = nil,
592+
final: Bool = false
593+
) {
589594
self.requestId = id
590595
self.status = status
591596
self.headers = headers
@@ -604,14 +609,20 @@ internal struct LambdaHTTPServer {
604609
let headers = HTTPHeaders([
605610
(AmazonHeaders.requestID, self.requestId),
606611
(
607-
AmazonHeaders.invokedFunctionARN,
608-
"arn:aws:lambda:us-east-1:\(Int16.random(in: Int16.min ... Int16.max)):function:custom-runtime"
612+
AmazonHeaders.invokedFunctionARN,
613+
"arn:aws:lambda:us-east-1:\(Int16.random(in: Int16.min ... Int16.max)):function:custom-runtime"
609614
),
610615
(AmazonHeaders.traceID, "Root=\(AmazonHeaders.generateXRayTraceID());Sampled=1"),
611616
(AmazonHeaders.deadline, "\(DispatchWallTime.distantFuture.millisSinceEpoch)"),
612617
])
613618

614-
return LocalServerResponse(id: self.requestId, status: .accepted, headers: headers, body: self.request, final: true)
619+
return LocalServerResponse(
620+
id: self.requestId,
621+
status: .accepted,
622+
headers: headers,
623+
body: self.request,
624+
final: true
625+
)
615626
}
616627
}
617628
}

0 commit comments

Comments
 (0)