|
12 | 12 | //
|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
15 |
| -extension APIGateway { |
16 |
| - public struct V2 {} |
17 |
| -} |
| 15 | +/// APIGatewayV2Request contains data coming from the new HTTP API Gateway |
| 16 | +struct APIGatewayV2Request: Codable { |
| 17 | + /// Context contains the information to identify the AWS account and resources invoking the Lambda function. |
| 18 | + public struct Context: Codable { |
| 19 | + public struct HTTP: Codable { |
| 20 | + public let method: HTTPMethod |
| 21 | + public let path: String |
| 22 | + public let `protocol`: String |
| 23 | + public let sourceIp: String |
| 24 | + public let userAgent: String |
| 25 | + } |
18 | 26 |
|
19 |
| -extension APIGateway.V2 { |
20 |
| - /// APIGateway.V2.Request contains data coming from the new HTTP API Gateway |
21 |
| - public struct Request: Codable { |
22 |
| - /// Context contains the information to identify the AWS account and resources invoking the Lambda function. |
23 |
| - public struct Context: Codable { |
24 |
| - public struct HTTP: Codable { |
25 |
| - public let method: HTTPMethod |
26 |
| - public let path: String |
27 |
| - public let `protocol`: String |
28 |
| - public let sourceIp: String |
29 |
| - public let userAgent: String |
| 27 | + /// Authorizer contains authorizer information for the request context. |
| 28 | + public struct Authorizer: Codable { |
| 29 | + /// JWT contains JWT authorizer information for the request context. |
| 30 | + public struct JWT: Codable { |
| 31 | + public let claims: [String: String] |
| 32 | + public let scopes: [String]? |
30 | 33 | }
|
31 | 34 |
|
32 |
| - /// Authorizer contains authorizer information for the request context. |
33 |
| - public struct Authorizer: Codable { |
34 |
| - /// JWT contains JWT authorizer information for the request context. |
35 |
| - public struct JWT: Codable { |
36 |
| - public let claims: [String: String] |
37 |
| - public let scopes: [String]? |
38 |
| - } |
39 |
| - |
40 |
| - public let jwt: JWT |
41 |
| - } |
| 35 | + public let jwt: JWT |
| 36 | + } |
42 | 37 |
|
43 |
| - public let accountId: String |
44 |
| - public let apiId: String |
45 |
| - public let domainName: String |
46 |
| - public let domainPrefix: String |
47 |
| - public let stage: String |
48 |
| - public let requestId: String |
| 38 | + public let accountId: String |
| 39 | + public let apiId: String |
| 40 | + public let domainName: String |
| 41 | + public let domainPrefix: String |
| 42 | + public let stage: String |
| 43 | + public let requestId: String |
49 | 44 |
|
50 |
| - public let http: HTTP |
51 |
| - public let authorizer: Authorizer? |
| 45 | + public let http: HTTP |
| 46 | + public let authorizer: Authorizer? |
52 | 47 |
|
53 |
| - /// The request time in format: 23/Apr/2020:11:08:18 +0000 |
54 |
| - public let time: String |
55 |
| - public let timeEpoch: UInt64 |
56 |
| - } |
| 48 | + /// The request time in format: 23/Apr/2020:11:08:18 +0000 |
| 49 | + public let time: String |
| 50 | + public let timeEpoch: UInt64 |
| 51 | + } |
57 | 52 |
|
58 |
| - public let version: String |
59 |
| - public let routeKey: String |
60 |
| - public let rawPath: String |
61 |
| - public let rawQueryString: String |
| 53 | + public let version: String |
| 54 | + public let routeKey: String |
| 55 | + public let rawPath: String |
| 56 | + public let rawQueryString: String |
62 | 57 |
|
63 |
| - public let cookies: [String]? |
64 |
| - public let headers: HTTPHeaders |
65 |
| - public let queryStringParameters: [String: String]? |
66 |
| - public let pathParameters: [String: String]? |
| 58 | + public let cookies: [String]? |
| 59 | + public let headers: HTTPHeaders |
| 60 | + public let queryStringParameters: [String: String]? |
| 61 | + public let pathParameters: [String: String]? |
67 | 62 |
|
68 |
| - public let context: Context |
69 |
| - public let stageVariables: [String: String]? |
| 63 | + public let context: Context |
| 64 | + public let stageVariables: [String: String]? |
70 | 65 |
|
71 |
| - public let body: String? |
72 |
| - public let isBase64Encoded: Bool |
| 66 | + public let body: String? |
| 67 | + public let isBase64Encoded: Bool |
73 | 68 |
|
74 |
| - enum CodingKeys: String, CodingKey { |
75 |
| - case version |
76 |
| - case routeKey |
77 |
| - case rawPath |
78 |
| - case rawQueryString |
| 69 | + enum CodingKeys: String, CodingKey { |
| 70 | + case version |
| 71 | + case routeKey |
| 72 | + case rawPath |
| 73 | + case rawQueryString |
79 | 74 |
|
80 |
| - case cookies |
81 |
| - case headers |
82 |
| - case queryStringParameters |
83 |
| - case pathParameters |
| 75 | + case cookies |
| 76 | + case headers |
| 77 | + case queryStringParameters |
| 78 | + case pathParameters |
84 | 79 |
|
85 |
| - case context = "requestContext" |
86 |
| - case stageVariables |
| 80 | + case context = "requestContext" |
| 81 | + case stageVariables |
87 | 82 |
|
88 |
| - case body |
89 |
| - case isBase64Encoded |
90 |
| - } |
| 83 | + case body |
| 84 | + case isBase64Encoded |
91 | 85 | }
|
92 | 86 | }
|
93 | 87 |
|
94 |
| -extension APIGateway.V2 { |
95 |
| - public struct Response: Codable { |
96 |
| - public var statusCode: HTTPResponseStatus |
97 |
| - public var headers: HTTPHeaders? |
98 |
| - public var body: String? |
99 |
| - public var isBase64Encoded: Bool? |
100 |
| - public var cookies: [String]? |
101 |
| - |
102 |
| - public init( |
103 |
| - statusCode: HTTPResponseStatus, |
104 |
| - headers: HTTPHeaders? = nil, |
105 |
| - body: String? = nil, |
106 |
| - isBase64Encoded: Bool? = nil, |
107 |
| - cookies: [String]? = nil |
108 |
| - ) { |
109 |
| - self.statusCode = statusCode |
110 |
| - self.headers = headers |
111 |
| - self.body = body |
112 |
| - self.isBase64Encoded = isBase64Encoded |
113 |
| - self.cookies = cookies |
114 |
| - } |
| 88 | +public struct APIGatewayV2Response: Codable { |
| 89 | + public var statusCode: HTTPResponseStatus |
| 90 | + public var headers: HTTPHeaders? |
| 91 | + public var body: String? |
| 92 | + public var isBase64Encoded: Bool? |
| 93 | + public var cookies: [String]? |
| 94 | + |
| 95 | + public init( |
| 96 | + statusCode: HTTPResponseStatus, |
| 97 | + headers: HTTPHeaders? = nil, |
| 98 | + body: String? = nil, |
| 99 | + isBase64Encoded: Bool? = nil, |
| 100 | + cookies: [String]? = nil |
| 101 | + ) { |
| 102 | + self.statusCode = statusCode |
| 103 | + self.headers = headers |
| 104 | + self.body = body |
| 105 | + self.isBase64Encoded = isBase64Encoded |
| 106 | + self.cookies = cookies |
115 | 107 | }
|
116 | 108 | }
|
0 commit comments