在AWS Lambda代码中,如何获取来自AWS Gateway API的HTTP请求的HTTP方法(例如GET,POST ...)?
我从文档中了解到context.httpMethod是解决方案.
但是,我无法让它发挥作用.
例如,当我尝试添加以下3行时:
if (context.httpMethod) {
console.log('HTTP method:', context.httpMethod)
}
Run Code Online (Sandbox Code Playgroud)
进入"microservice-http-endpoint"蓝图的AWS示例代码如下:
exports.handler = function(event, context) {
if (context.httpMethod) {
console.log('HTTP method:', context.httpMethod)
}
console.log('Received event:', JSON.stringify(event, null, 2));
// For clarity, I have removed the remaining part of the sample
// provided by AWS, which works well, for instance when triggered
// with Postman through the API Gateway as an intermediary.
};
Run Code Online (Sandbox Code Playgroud)
我从来没有在日志中有任何东西因为httpMethod总是空的.
我正在使用MEAN.JS(https://github.com/meanjs/mean)和angular-file-upload(https://github.com/danialfarid/angular-file-upload).
MEAN.JS提供的"Article"样本包含两个名为"title"和"content"的字段.我想修改它并添加一个"图片"字段,允许用户上传图片.
我知道我必须在MEAN.JS中修改3个文件:
~myproject/app/models/article.server.model.js
~myproject/public/modules/articles/controllers/articles.client.controller.js
~myproject/public/modules/articles/views/create-article.client.view.html
Run Code Online (Sandbox Code Playgroud)
但是,我无法成功修改它们.
如果我使用以下代码计算蒙得维的亚当前的当地时间:
var dt = new Date().toLocaleString("en-US", {timeZone: "America/Montevideo"})
console.log(dt);
Run Code Online (Sandbox Code Playgroud)
我明白了:
2015年11月29日上午9:46:10
如果我在网上查看这个时间,例如:http: //www.zeitverschiebung.net/en/timezone/america--montevideo 我得到:
2015年11月29日上午8:46:10
为什么1小时差异?