Update per 20-9-2016
Amazon finally made this easy using the Lambda Proxy integration. This allows your Lambda function to return proper HTTP codes and headers:
let response = {
statusCode: '400',
body: JSON.stringify({ error: 'you messed up!' }),
headers: {
'Content-Type': 'application/json',
}
};
context.succeed(response);
Say goodbye request/response mapping in the API Gateway!
Option 2
Integrate an existing Express app with Lambda/API Gateway using aws-serverless-express.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…