[英]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.