vapor-community / vapor-aws-lambda-runtime

Run your Vapor api server on AWS Lambda using the official Swift Server runtime.
Apache License 2.0
104 stars 10 forks source link

Debugging #10

Closed fcobia closed 3 years ago

fcobia commented 3 years ago

I used this project to create a Vapor Leaf project through Lambda and API Gateway. I discovered 2 issues which this PR fixes. These bugs are specific to the API Gateway 2.0 format (https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html).

1) In the 2.0 integration, multiValueHeaders is no longer used, which causes the headers of the Vapor response to be lost. This causes the browser to interpret the HTML response as text and it fails to render.

2) The query parameters of the request were not being passed to my Vapor code. I put a fix to pass the query parameters.

codecov[bot] commented 3 years ago

Codecov Report

Merging #10 into main will decrease coverage by 0.00%. The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##            main     #10      +/-   ##
========================================
- Coverage   0.02%   0.02%   -0.01%     
========================================
  Files        509     518       +9     
  Lines      36361   38182    +1821     
========================================
  Hits           8       8              
- Misses     36353   38174    +1821     
Impacted Files Coverage Δ
Sources/VaporAWSLambdaRuntime/APIGateway.swift 0.00% <ø> (ø)
Sources/VaporAWSLambdaRuntime/APIGatewayV2.swift 0.00% <0.00%> (ø)
Sources/VaporAWSLambdaRuntime/LambdaServer.swift 0.00% <ø> (ø)
...build/checkouts/swift-nio/Sources/NIO/Socket.swift 0.00% <0.00%> (ø)
...build/checkouts/swift-nio/Sources/NIO/System.swift 0.00% <0.00%> (ø)
...ild/checkouts/swift-nio/Sources/NIO/PipePair.swift 0.00% <0.00%> (ø)
...ld/checkouts/swift-nio/Sources/NIO/Bootstrap.swift 0.00% <0.00%> (ø)
...d/checkouts/swift-nio/Sources/NIO/BaseSocket.swift 0.00% <0.00%> (ø)
...checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift 0.00% <0.00%> (ø)
...checkouts/swift-nio/Sources/NIO/ServerSocket.swift 0.00% <0.00%> (ø)
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7a35ef5...491867f. Read the comment docs.

fcobia commented 3 years ago

@fabianfett I merged your suggested code change for the cookies, because it did look correct and was more concise. However, when I actually ran my Vapor app in Lambda, it broke.

I probably will not have time for a week or two to look at why that broke it, but I reverted that code back. I did do the swiftformat.

I will leave it up to you whether you want to merge the code or not. It does work and allows Vapor apps to run, but I understand if you would rather wait to figure out why the more concise code does not work and to add unit tests.