x-amazon-apigateway-integration.response 对象 - Amazon API Gateway
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

x-amazon-apigateway-integration.response 对象

定义响应并指定从集成响应到方法响应的参数映射或负载映射。

属性
属性名称 类型 说明
statusCode string

方法响应的 HTTP 状态代码,例如 "200"。必须对应 OpenAPI 操作responses字段中的匹配响应。

responseTemplates x-amazon-apigateway-integration.responseTemplates 对象

为响应的负载指定特定于 MIME 类型的映射模板。

responseParameters x-amazon-apigateway-integration.responseParameters 对象

指定响应的参数映射。仅集成响应的 headerbody 参数可以映射到方法的 header 参数。

contentHandling string 响应负载编码转换类型。有效值为 1) CONVERT_TO_TEXT,用于将二进制负载转换为 Base64 编码字符串,或者将文本负载转换为 utf-8 编码字符串,或者在无任何修改的情况下直接传递文本负载,以及 2) CONVERT_TO_BINARY,用于将文本负载转换为 Base64 解码的二进制大型对象,或者在无任何修改的情况下直接传递二进制负载。

x-amazon-apigateway-integration.response 示例

下面的示例为从后端获得 302application/json MIME 类型负载的方法定义了 application/xml 响应。该响应使用提供的映射模板,从方法的 Location 标头中的集成响应中返回重定向 URL。

{ "statusCode" : "302", "responseTemplates" : { "application/json" : "#set ($root=$input.path('$')) { \"stage\": \"$root.name\", \"user-id\": \"$root.key\" }", "application/xml" : "#set ($root=$input.path('$')) <stage>$root.name</stage> " }, "responseParameters" : { "method.response.header.Location": "integration.response.body.redirect.url" } }