1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 在API Gateway 访问日志中记录头信息可能并不可行。根据文档,只有以下变量可以记录从API Gateway访问日志到Cloudwatch - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging-variables.html。
话虽如此,在后端集成lambda中记录头信息是可能的。
我使用了这个教程https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-dynamo-db.html,只需修改lambda函数代码即可记录事件对象。
const AWS = require("aws-sdk"); const dynamo = new AWS.DynamoDB.DocumentClient(); exports.handler = async (event, context) => { let body; let statusCode = 200; const headers = { "Content-Type": "application/json" }; console.log("#####################") console.log(event) console.log("#####################") try { .....其余的代码
当我从API Gateway调用API时,我确实可以看到头信息被记录在lambda函数的Cloudwatch日志中。
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前