x-amazon-apigateway-any-方法對象 - Amazon API Gateway

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

x-amazon-apigateway-any-方法對象

OpenAPI 路徑項目物件中指定 API Gateway 全部截獲 ANY 方法的 OpenAPI 操作物件。此物件會與其他操作物件並存,並會截獲未明確宣告的任何 HTTP 方法。

下表列有 API Gateway 延伸的屬性。如需其他 OpenAPI 操作屬性,請參閱 OpenAPI 規定。

屬性
屬性名稱 類型 描述
isDefaultRoute Boolean 指定路由是否為 $default 路由。僅支援 HTTP API。如需進一步了解,請參閱在 API Gateway 中為 HTTP API 建立路由
x-amazon-apigateway-integration x-amazon-apigateway-integration 物件 指定方法與後端的整合。這是 OpenAPI 操作物件的延伸屬性。整合類型可為 AWSAWS_PROXYHTTPHTTP_PROXYMOCK

x-amazon-apigateway-any-方法示例

下列範例會整合代理資源 ANY{proxy+} 方法與 Lambda 函數 TestSimpleProxy

"/{proxy+}": { "x-amazon-apigateway-any-method": { "produces": [ "application/json" ], "parameters": [ { "name": "proxy", "in": "path", "required": true, "type": "string" } ], "responses": {}, "x-amazon-apigateway-integration": { "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:TestSimpleProxy/invocations", "httpMethod": "POST", "type": "aws_proxy" }

下列範例會為 HTTP API 建立與 Lambda 函數 $default 整合的 HelloWorld 路由。

"/$default": { "x-amazon-apigateway-any-method": { "isDefaultRoute": true, "x-amazon-apigateway-integration": { "type": "AWS_PROXY", "httpMethod": "POST", "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:HelloWorld/invocations", "timeoutInMillis": 1000, "connectionType": "INTERNET", "payloadFormatVersion": 1.0 } } }