是否可以将API网关与AWS lambda中的节点路由连接?

问题描述:

我已经使用AWSServerlessExpress实现了节点应用程序,并在Lambda函数中进行了部署.但无法将API网关指向节点路由.每次我获得404状态.

I have implemented node application with AWSServerlessExpress and deployed in Lambda function. but unable to point API Gateway to node routes. every time I'm getting 404 status.

var express = require('express')
, router = express.Router()

router.post('/es', function(request, response){
    response.status(200).send("Lambda is triggered");
    response.end()
})

router.get('/es/csv', function(request, response){
    response.status(200).send("hello");
    response.end()
})

module.exports = router;

如何直接指向API网关以获取或发布"路线?

How can I point API gateway directly to get Or Post route?

浏览了AWS文档之后,我找到了解决我问题的方法.要将请求从API网关转发到lambda中的节点路由,我们必须在API网关中创建一个新的代理({proxy +})资源,该资源下可以根据您的要求创建任何方法.

After gone through the AWS documentation I have found a solution to my question. To forward the request from API Gateway to node routes in lambda we have to create a new proxy ({proxy+})resource in API gateway under this resource create any method(based on your requirement).

我在这里找到了这个答案:

I found this answer here: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-create-api-as-simple-proxy