我想在我的聊天机器人上显示链接。
message: { contentType: 'PlainText', content:"<a href="www.google.com">Test Result</a>" },html标记按原样显示。如何将内容显示为html?
发布于 2017-10-21 03:47:38
您需要在响应对象的headers中将content-type设置为text/html,因为通常将其(隐式)设置为application/json。
根据您的情况,您需要在AWS Lambda处理程序中返回函数,如下所示:
callback(null, {
statusCode: 200,
headers: {"content-type": "text/html"},
body: "<html><body>OK</body></html>"
})这将为客户端解析设置正确的内容类型。
发布于 2019-08-27 06:54:03
对于那些使用无服务器框架的用户,您可以在serverless.yml文件中配置函数响应的内容类型,例如:
downloadImage:
handler: lib/client-app-services.downloadImage
events:
- http:
path: client/images/{filename}
method: get
cors: true
integration: lambda
response:
headers:
Content-Type: "'image/jpeg'"
Cache-Control: "'max-age=120'"https://stackoverflow.com/questions/46171369
复制相似问题