我想從處理程序返回值到API網關響應標頭。Lambda和API網關映射
Handler.js
module.exports.handler = function(event, context, cb) {
const UpdateDate = new Date();
return cb(null, {
body: {
message: 'test'
},
header: {
Last-Modified: UpdateDate
}
});
};
S-function.json在 「端點」
"responses": {
"400": {
"statusCode": "400"
},
"default": {
"statusCode": "200",
"responseParameters": {
"method.response.header.Cache-Control": "'public, max-age=86400'",
"method.response.header.Last-Modified": "integration.response.body.header.Last-Modified"
},
"responseModels": {
"application/json;charset=UTF-8": "Empty"
},
"responseTemplates": {
"application/json;charset=UTF-8": "$input.json('$.body')"
}
}
}
這可以工作。但我想知道如何使用「integration.response.header.Last-Modified」。我的處理程序回調formate是否錯誤?
編輯: S-function.json在 「端點」
「integration.response.header.Last修飾」 這是行不通的。 我想知道具體的處理返回合成將數據傳遞給「integration.response.header.Last-Modified」。
"responses": {
"400": {
"statusCode": "400"
},
"default": {
"statusCode": "200",
"responseParameters": {
"method.response.header.Cache-Control": "'public, max-age=86400'",
"method.response.header.Last-Modified": "integration.response.header.Last-Modified"
},
"responseModels": {
"application/json;charset=UTF-8": "Empty"
},
"responseTemplates": {
"application/json;charset=UTF-8": "$input.json('$.body')"
}
}
}
這看起來乍一看正確的,但我不明白你的問題。你是說這個*不工作嗎?如果不是,你看到了什麼行爲? –
我想使用「integration.response.header.Last-Modified」,我不知道lambda歸還合成。 – Jim