swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.13k stars 102 forks source link

Other HttpMethod support for local server #158

Closed saltzmanjoelh closed 4 years ago

saltzmanjoelh commented 4 years ago

Awesome work everyone! Thank you so much 🙏 I might be doing something wrong but the local server seems to only support POST

Expected behavior

Th local server should support the other HttpMethods.

Actual behavior

If I comment out request.httpMethod = "POST" so that I can try GET in the example ContentView.swift I get "resource exceeds maximum size"

Steps to reproduce

Comment out request.httpMethod = "POST" so that I can try GET in the example ContentView.swift Run iOS project again, fill in the fields and hit Regiser

SwiftAWSLambdaRuntime version/commit hash

Latest f3c68d66c46be889dea45ddfdac57168d09e59cc

Swift & OS version (output of swift --version && uname -a)

Apple Swift version 5.3 (swiftlang-1200.0.25.2 clang-1200.0.27.1) Target: x86_64-apple-darwin20.0.0 Darwin Joels-MBP.lan 20.0.0 Darwin Kernel Version 20.0.0: Thu Jul 30 22:49:28 PDT 2020; root:xnu-7195.0.0.141.5~1/RELEASE_X86_64 x86_64

fabianfett commented 4 years ago

Hi @saltzmanjoelh, thanks for bringing this up.

The local debug server currently tries to mimic the Lambda invoke api from AWS as closely as possible. Not requiring the POST method would allow users to send requests to GET locally, but as soon as they deploy to AWS Lambda their code wouldn't work anymore. Again, please note that this is only about the invoke.

From your question I assume that you are looking for guidance on how to implement a simple HTTP/REST API. In this case I recommend you to read my tutorial Create your first HTTP endpoint with Swift on AWS Lambda.

If you have any further questions please reach out.

Please note that we look into making debugging for API Gateways Lambdas easier (#138, #83).