在Lambda代理集成中,API Gateway将整个客户端请求映射到Lambda函数的输入event
参数.
这个event
参数是Lambda proxy integration request,有效负载的格式取决于您使用的是有效负载的版本1还是版本2;这两个版本的模式都列在docs中.
REST API和amp;WebSocket API仅支持将v1有效负载发送到Lambda代理集成.Http API支持同时发送v1和v2,但通过控制台,它们被配置为by default发送最新版本(目前是v2).
Note to not confuse this with the namespaces that you'd see in the CLI, APIs, CloudFormation, SDKs, or AWS SAM. While the API V1 namespace represents REST APIs & API V2 represents WebSocket and HTTP APIs, the 'namespace versions' do not align with the payload versions.个
对于REST API(V1),对您的端点的最小请求可能如下所示:
{
"version": "1.0",
"resource": "/get-student/{student_id}",
"path": "/get-student/1",
"httpMethod": "GET",
"pathParameters": {
"student_id": "1"
}
}
对于HTTP API(V2),对您的端点的最小请求可能如下所示:
{
"version": "2.0",
"routeKey": "GET /get-student/{student_id}",
"rawPath": "/get-student/1",
"pathParameters": {
"student_id": "1"
}
}
在大多数AWS SDK中,例如用于.NET的开发工具包,代理集成请求以类的形式提供,即APIGatewayProxyRequest
(V1)/APIGatewayHttpApiV2ProxyRequest
(V2).