Phi*_*ito 7 python amazon-web-services aws-lambda aws-api-gateway
我有一个响应方法,看起来像我的Lambda函数:
def respond(err, res=None):
return {
'statusCode': 400 if err else 200,
'body': json.dumps(err) if err else json.dumps(res),
'headers': {
'Access-Control-Allow-Headers': 'content-type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token',
'Access-Control-Allow-Methods': 'POST, GET, DELETE',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': True,
'Content-Type': 'application/json',
},
}
Run Code Online (Sandbox Code Playgroud)
当我使用Postman的OPTIONS请求测试我的端点时,我收到500内部服务器错误.如果我从API网关控制台测试它,我另外得到这个:
Execution log for request test-request
Wed Jul 05 14:25:26 UTC 2017 : Starting execution for request: test-invoke-request
Wed Jul 05 14:25:26 UTC 2017 : HTTP Method: OPTIONS, Resource Path: /login
Wed Jul 05 14:25:26 UTC 2017 : Method request path: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request query string: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request headers: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request body before transformations:
Wed Jul 05 14:25:26 UTC 2017 : Received response. Integration latency: 0 ms
Wed Jul 05 14:25:26 UTC 2017 : Endpoint response body before transformations:
Wed Jul 05 14:25:26 UTC 2017 : Endpoint response headers: {}
Wed Jul 05 14:25:26 UTC 2017 : Execution failed due to configuration error: Output mapping refers to an invalid method response: 200
Wed Jul 05 14:25:26 UTC 2017 : Method completed with status: 500
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么.我想我正在返回所有正确的标题.任何帮助表示赞赏.
| 归档时间: |
|
| 查看次数: |
789 次 |
| 最近记录: |