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

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

x-amazon-apigateway-gateway-responses.responseTemp

将给定网关响应的GatewayResponse string-to-string 映射模板定义为键值对的映射。对于每个键/值对,“键”指内容类型。例如“application/json”,而“值”指简单变量替换的字符串化映射模板。GatewayResponse 映射模板不由 Velocity 模板语言 (VTL) 引擎处理。

属性
属性名称 类型 说明
content-type string

GatewayResponse 正文映射模板,仅支持简单变量替换以自定义网关响应正文。

x-amazon-apigateway-gateway-响应.响应模板示例

以下 OpenAPI 扩展示例显示了一个GatewayResponse映射模板,用于将 API 网关生成的错误响应自定义为特定于应用程序的格式。

"responseTemplates": { "application/json": "{ \"message\": $context.error.messageString, \"type\":$context.error.responseType, \"statusCode\": '488' }" }

以下 OpenAPI 扩展示例显示了一个GatewayResponse映射模板,用于使用静态错误消息覆盖 API 网关生成的错误响应。

"responseTemplates": { "application/json": "{ \"message\": 'API-specific errors' }" }