Skip to content

Commit cbc5418

Browse files
committed
More PR comments; rebase on top of #91
1 parent e9b5e79 commit cbc5418

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

Sources/AWSLambdaEvents/APIGateway+V2.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public struct APIGatewayV2Request: Encodable, Sendable {
126126
}
127127
}
128128

129+
extension APIGatewayV2Request: DecodableRequest {}
130+
129131
public struct APIGatewayV2Response: Codable, Sendable {
130132
public var statusCode: HTTPResponse.Status
131133
public var headers: HTTPHeaders?
@@ -148,6 +150,8 @@ public struct APIGatewayV2Response: Codable, Sendable {
148150
}
149151
}
150152

153+
extension APIGatewayV2Response: EncodableResponse {}
154+
151155
extension APIGatewayV2Request: Decodable {
152156
public init(from decoder: Decoder) throws {
153157
let container = try decoder.container(keyedBy: CodingKeys.self)

Sources/AWSLambdaEvents/Codable Helpers/DecodableRequest.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,3 @@ extension DecodableRequest {
7373
return try decoder.decode(T.self, from: requestData)
7474
}
7575
}
76-
77-
extension APIGatewayV2Request: DecodableRequest {}
78-
extension FunctionURLRequest: DecodableRequest {}

Sources/AWSLambdaEvents/Codable Helpers/EncodableResponse.swift

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public protocol EncodableResponse {
3434
statusCode: HTTPResponse.Status,
3535
headers: HTTPHeaders?,
3636
body: String?,
37-
cookies: [String]?,
38-
isBase64Encoded: Bool?
37+
isBase64Encoded: Bool?,
38+
cookies: [String]?
3939
)
4040
}
4141

@@ -66,8 +66,8 @@ extension EncodableResponse {
6666
statusCode: status,
6767
headers: headers,
6868
body: String(data: encodedResponse, encoding: .utf8),
69-
cookies: cookies,
70-
isBase64Encoded: nil
69+
isBase64Encoded: nil,
70+
cookies: cookies
7171
)
7272
} catch {
7373
return onError(error)
@@ -80,28 +80,9 @@ extension EncodableResponse {
8080
statusCode: .internalServerError,
8181
headers: nil,
8282
body: "Internal Server Error: \(String(describing: error))",
83-
cookies: nil,
84-
isBase64Encoded: nil
83+
isBase64Encoded: nil,
84+
cookies: nil
8585
)
8686
}
8787
}
8888
}
89-
90-
extension APIGatewayV2Response: EncodableResponse {
91-
public init(
92-
statusCode: HTTPResponse.Status,
93-
headers: HTTPHeaders?,
94-
body: String?,
95-
cookies: [String]?,
96-
isBase64Encoded: Bool?
97-
) {
98-
self.init(
99-
statusCode: statusCode,
100-
headers: headers,
101-
body: body,
102-
isBase64Encoded: isBase64Encoded,
103-
cookies: cookies
104-
)
105-
}
106-
}
107-
extension FunctionURLResponse: EncodableResponse {}

Sources/AWSLambdaEvents/FunctionURL.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public struct FunctionURLRequest: Codable, Sendable {
8383
public let stageVariables: [String: String]?
8484
}
8585

86+
extension FunctionURLRequest: DecodableRequest {}
87+
8688
// MARK: - Response -
8789

8890
public struct FunctionURLResponse: Codable, Sendable {
@@ -121,3 +123,5 @@ public struct FunctionURLResponse: Codable, Sendable {
121123
self.isBase64Encoded = isBase64Encoded
122124
}
123125
}
126+
127+
extension FunctionURLResponse: EncodableResponse {}

0 commit comments

Comments
 (0)