How to transform HTTP requests to Lambda events exactly as AWS API Gateway does as an HTTP proxy?

0

I'm developing a Lambda service behind an API Gateway as an HTTP proxy[1].

As the docs say, API Gateway basically transforms the HTTP request into a JSON Lambda Event.

In order to support the development process, I wonder if there is a library I could use to do that: transform an HTTP request into a JSON Lambda Event.

That way I could develop locally, wrapping my lambda implementation in a dummy web server whose work would be to transform and pass the event to my code.

[1] https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

jgomo3
已提问 1 年前822 查看次数
1 回答
1

I recommends that you use SAM CLI for local testing. Using SAM CLI you can invoke your functions locally using the sam local start-api command, that will start also a local API gateway and will invoke your code when you CURL the local end-point. You could also use sam local generate-event to create the event object that is used by API Gateway and use it when invoking the function directly using sam local invoke.

profile pictureAWS
专家
Uri
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则