kag*_*kij 4 python aws-lambda aws-api-gateway
我有用 Python 2.7 编写的 Lambda 函数,它是从 API 网关触发的,
我希望 API Gateway 在 Lambda 失败时返回 400 代码并且我不想使用 Lambda 代理,因此我正在尝试设置 API Gateway 集成响应。
当 Lambda 函数失败时,它返回:
{
"stackTrace": [
[
"/var/task/lambda_function.py",
12,
"lambda_handler",
"raise Exception('failure')"
]
],
"errorType": "Exception",
"errorMessage": "failure"
}
Run Code Online (Sandbox Code Playgroud)
..同样来自 CLI:
aws apigateway get-integration-response --rest-api-id bz47krygwa --resource-id 788q0w --http-method ANY --status-code 400 --region us-west-1
{
"statusCode": "400",
"selectionPattern": ".*\"failure\".*",
"responseTemplates": {
"application/json": "#set($inputRoot = $input.path('$.errorMessage'))\n$inputRoot"
}
}
Run Code Online (Sandbox Code Playgroud)
请修复任何建议?
归档时间: |
|
查看次数: |
5795 次 |
最近记录: |