AWS API Gateway配置GET方法,导出集成方法显示POST是否正常?
AWS API Gateway GET方法集成配置显示POST的原因
这是正常行为,不是BUG,核心原因在于你使用的是Lambda代理集成(aws_proxy类型):
- Lambda的调用接口(Invocation API)本身要求通过POST方法触发,所以无论你在API Gateway上配置的前端HTTP方法是GET、POST还是其他类型,API Gateway都会以POST请求来调用Lambda函数。
- 你看到的
"httpMethod": "POST"是API Gateway与Lambda之间的通信方法,而对外暴露给客户端的仍然是你配置的GET方法,两者互不冲突。 - API Gateway会自动把前端GET请求的所有上下文信息(路径参数、查询参数、请求头部等)封装成Lambda兼容的事件结构,通过POST请求传递给Lambda,再将Lambda的响应结果返回给客户端。
你可以正常测试该GET接口,功能不受影响。
你提供的配置片段:
"paths" : { "/api/{proxy+}" : { "get" : { "parameters" : [ { "name" : "proxy", "in" : "path", "required" : true, "schema" : { "type" : "string" } } ], "responses" : { "200" : { "description" : "200 response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Empty" } } } } }, "x-amazon-apigateway-integration" : { "type" : "aws_proxy", "httpMethod" : "POST", "uri" : "arn:aws:apigateway:ap-south-1:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-south-1:233646325951:function:admingui/invocations", "responses" : { "default" : { "statusCode" : "200" } }, "passthroughBehavior" : "when_no_match", "cacheNamespace" : "i2ndmg", "cacheKeyParameters" : [ "method.request.path.proxy" ], "contentHandling" : "CONVERT_TO_TEXT" } } } }
内容的提问来源于stack exchange,提问作者Arun Rajarao
相关产品推荐
相关产品推荐

