-
Notifications
You must be signed in to change notification settings - Fork 113
Add apigateway and alb #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3cf0a25
to
273ea5c
Compare
Sources/AWSLambdaEvents/ALB.swift
Outdated
self.isBase64Encoded = try container.decode(Bool.self, forKey: .isBase64Encoded) | ||
|
||
let body = try container.decode(String.self, forKey: .body) | ||
self.body = body != "" ? body : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restore the PW from SNS?
Sources/AWSLambdaEvents/ALB.swift
Outdated
) | ||
let multiValueHeaders = singleValueHeaders.mapValues { [$0] } | ||
self.headers = HTTPHeaders(multiValueHeaders) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract with PW?
Sources/AWSLambdaEvents/ALB.swift
Outdated
forKey: .queryStringParameters | ||
) | ||
self.queryStringParameters = singleValueQueryStringParameters.mapValues { [$0] } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract with PW?
Sources/AWSLambdaEvents/ALB.swift
Outdated
debugDescription: #"Method "\#(rawMethod)" does not conform to allowed http method syntax defined in RFC 7230 Section 3.2.6"# | ||
) | ||
} | ||
self.httpMethod = method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract with PW?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh actually isn't HTTPMethod Codable now? so this check could go there?
hey @fabianfett should we bring this over the finish line? |
273ea5c
to
25c8dd4
Compare
@@ -54,7 +54,8 @@ public enum APIGateway { | |||
|
|||
public let queryStringParameters: [String: String]? | |||
public let multiValueQueryStringParameters: [String: [String]]? | |||
public let headers: HTTPHeaders | |||
public let headers: [String: String] | |||
public let multiValueHeaders: [String: [String]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider a type alias for headers and multiValueHeaders, ie typealias HTTPHeaders = [String: String]
and typealias HTTPMultiValueHeaders = [String: [String]]
will make it easier to refactor in case we one day want to build functionality around them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed...
XCTAssertEqual(event.isBase64Encoded, false) | ||
// XCTAssertEqual(event.headers.count, 11) | ||
XCTAssertEqual(event.headers?.count, 11) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which dead code do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry my bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this simplification allot. one suggestion re. type alias for headers for future use.
XCTAssertEqual(request.httpMethod, .POST) | ||
|
||
// let todo = try request.decodeBody(Todo.self) | ||
// XCTAssertEqual(todo.title, "a todo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove dead code
// MARK: HTTPMethod | ||
|
||
public typealias Headers = [String: String] | ||
public typealias MultiValueHeaders = [String: [String]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should those be named with prefix HTTP?
|
||
import class Foundation.JSONEncoder | ||
|
||
// https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you know about API Gateway's v2 integration with lambda? https://aws.amazon.com/blogs/compute/building-better-apis-http-apis-now-generally-available/
By default, it's request/response shape is different, and requires a configuration to be compatible with the "1.0" shape you've got here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomerd let me see what I can do to get this to work today. Since v2 already is GA, there might be a chance for us never to support v1. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomerd Okay I added the API Gateway v2 syntax, which in my opinion is much nicer. I've already tried it with my own lambda quite extensively. Works great and the v2 syntax is much easier to use, if you ask me.
809008b
to
a00c605
Compare
75ff881
to
ae07717
Compare
ae07717
to
cf2bc9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomerd This is ready for final review!
@fabianfett this looks like its ready to be merged, correct? |
This builds on top of #46.
HTTPHeaders
,HTTPMethod
andHTTPResponseStatus
in an AWS friendly way