我已经部署了 api 网关项目,该项目集成了返回 base64 编码响应的 lambda (不是代理)函数。示例响应如下所示(请记住,为了简单起见,我删除了一些亚马逊标头并更改了响应):
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 949
Connection: close
Date: Mon, 14 Dec 2020 15:20:39 GMT
X-Pagination-Offset: 0
X-Pagination-Count: 2
X-Pagination-Limit: 100
eyJib2R5IjogW3sidXVpZCI6ICI1M2EzZTk4My1mYjBkLTQ5MzEtYTc5NC1hYTI4NGEzZDNhYjMiLCAiY3JlYXRlZCI6ICIyMDIwLTExLTI3VDE3OjMwOjQzLjQwMTM3OFoifSwgeyJ1dWlkIjogImQyOTFiNmE0LWQ4NDctNGY5Ni05ZWVmLThlMDMyOGM2NjZhMiIsICJjcmVhdGVkIjogIjIwMjAtMTEtMjdUMTc6MzA6NDMuNDAxMjYzWiJ9XSwgImhlYWRlcnMiOiB7IkNvbnRlbnQtTGVuZ3RoIjogIjIwMyIsICJDb25uZWN0aW9uIjogImtlZXAtYWxpdmUiLCAiQWxsb3ciOiAiR0VULCBIRUFELCBPUFRJT05TIiwgIlgtUGFnaW5hdGlvbi1MaW1pdCI6ICIxMDAiLCAiWC1GcmFtZS1PcHRpb25zIjogIlNBTUVPUklHSU4iLCAiWC1QYWdpbmF0aW9uLUNvdW50IjogIjIiLCAiWC1QYWdpbmF0aW9uLU9mZnNldCI6ICIwIiwgIkNvbnRlbnQtRW5jb2RpbmciOiAiZ3ppcCIsICJWYXJ5IjogIkFjY2VwdC1FbmNvZGluZywgQ29va2llIiwgIkRhdGUiOiAiTW9uLCAxNCBEZWMgMjAyMCAxNToyMDozOSBHTVQiLCAiQ29udGVudC1UeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifSwgImNvZGUiOiAyMDB9
Run Code Online (Sandbox Code Playgroud)
解码前后的响应如下所示:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 949
Connection: close
Date: Mon, 14 Dec 2020 15:20:39 GMT
X-Pagination-Offset: 0
X-Pagination-Count: 2
X-Pagination-Limit: 100
eyJib2R5IjogW3sidXVpZCI6ICI1M2EzZTk4My1mYjBkLTQ5MzEtYTc5NC1hYTI4NGEzZDNhYjMiLCAiY3JlYXRlZCI6ICIyMDIwLTExLTI3VDE3OjMwOjQzLjQwMTM3OFoifSwgeyJ1dWlkIjogImQyOTFiNmE0LWQ4NDctNGY5Ni05ZWVmLThlMDMyOGM2NjZhMiIsICJjcmVhdGVkIjogIjIwMjAtMTEtMjdUMTc6MzA6NDMuNDAxMjYzWiJ9XSwgImhlYWRlcnMiOiB7IkNvbnRlbnQtTGVuZ3RoIjogIjIwMyIsICJDb25uZWN0aW9uIjogImtlZXAtYWxpdmUiLCAiQWxsb3ciOiAiR0VULCBIRUFELCBPUFRJT05TIiwgIlgtUGFnaW5hdGlvbi1MaW1pdCI6ICIxMDAiLCAiWC1GcmFtZS1PcHRpb25zIjogIlNBTUVPUklHSU4iLCAiWC1QYWdpbmF0aW9uLUNvdW50IjogIjIiLCAiWC1QYWdpbmF0aW9uLU9mZnNldCI6ICIwIiwgIkNvbnRlbnQtRW5jb2RpbmciOiAiZ3ppcCIsICJWYXJ5IjogIkFjY2VwdC1FbmNvZGluZywgQ29va2llIiwgIkRhdGUiOiAiTW9uLCAxNCBEZWMgMjAyMCAxNToyMDozOSBHTVQiLCAiQ29udGVudC1UeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifSwgImNvZGUiOiAyMDB9
Run Code Online (Sandbox Code Playgroud)
api网关响应映射模板$input.body用于上述响应。我只想返回body值。当我将映射模板更改为请求$util.base64Decode($input.body)的响应正文GET时
{
"code": 200,
"headers": {
"Allow": "GET, HEAD, OPTIONS",
"Content-Encoding": "gzip",
"Content-Type": "application/json",
"Date": "Mon, …Run Code Online (Sandbox Code Playgroud)