繁体   English   中英

AWS lambda和AWS lambda代理有什么区别?

[英]What is difference in AWS lambda and AWS lambda proxy?

我是AWS的新手。 我知道这可能是一个非常普通的问题。 但我试图通过并接受AWS lambda代理中的参数。 我能够使用body mapping模板在AWS lambda中做到这一点,有什么方法可以获取我们在Lambda代理中的AWS lambda中映射的queryString

如果您使用的是Lambda代理,则API Gateway会将整个客户端请求映射到后端lambda函数的输入事件参数,如下所示。

{
   "resource": "Resource path",
   "path": "Path parameter",
   "httpMethod": "Incoming request's method name"
   "headers": {Incoming request headers}
   "queryStringParameters": {query string parameters }
   "pathParameters":  {path parameters}
   "stageVariables": {Applicable stage variables}
   "requestContext": {Request context, including authorizer-returned key-value pairs}
   "body": "A JSON string of the request payload."
   "isBase64Encoded": "A boolean flag to indicate if the applicable request payload is Base64-encode"}

请参阅AWS的安装代理程序集成文档

这是如何解析事件数据(例如查询字符串)的示例

如果有人使用无服务器框架来开发和部署lambda和API网关,那么可以使用开放式API规范(又称为Swagger)将API网关配置为AWS lambda代理。 请参见以下配置示例。

 resources: Resources: SupportProxy: Type: "AWS::ApiGateway::RestApi" Properties: Name: lambda-proxy Description: "The API proxy entry point." Body: swagger: '2.0' info: version: '2016-09-12T23:19:28Z' title: ProxyResource basePath: /myapp schemes: - https # Work-around to prevent API Gateway from trying to re-encode binary files (images, fonts, etc) as unicode text. x-amazon-apigateway-binary-media-types: - '*/*' paths: /myapp/service1/{proxy+}: x-amazon-apigateway-any-method: parameters: - name: proxy in: path required: true type: string responses: {} x-amazon-apigateway-integration: responses: default: statusCode: '200' requestParameters: integration.request.path.proxy: method.request.path.proxy uri: ${service1.url}/{proxy} passthroughBehavior: when_no_match httpMethod: ANY type: http_proxy 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM