Him*_*hu 4 amazon-web-services aws-api-gateway
我从lambda后端获得一个字符串值(xml到string),应该以application/xml格式返回给最终用户.我怎样才能做到这一点?
您可以指定返回XML的Integration Response以及使用Lambda返回的对象格式化XML的映射模板.
我不相信有一种默认格式转换为XML.一个简单的映射模板可能是这样的:
#set($root = $input.path('$'))
<stuff>
<message>$root.message</message>
<sourceIp>$context.identity.sourceIp</sourceIp>
<outputs>
#foreach($key in $root.keySet())
<output>
<key>$key</key>
<value>$root.get($key)</value>
</output>
#end
</outputs>
</stuff>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4332 次 |
| 最近记录: |