admin管理员组文章数量:1376572
How do I return 401 to the client, based on the statusCode returned from the lambda? (non-proxy integration).
How do I return the headers from the headers
field? (for 401 and 200)
return {
"statusCode": 401,
"headers": {"myHeader": 'abcd "efg"'}
}
with this cdk:
unauthorized_integration_response = _api_gw.IntegrationResponse(
status_code="401",
response_parameters=response_integration_parameters,
selection_pattern='.*statusCode:401.*',
)
response_parameters = {
"method.response.header.Access-Control-Allow-Headers": True,
"method.response.header.Access-Control-Allow-Origin": True,
"method.response.header.Access-Control-Allow-Methods": True,
"method.response.header.Strict-Transport-Security": True,
"method.response.header.Content-Security-Policy": True,
"method.response.header.X-Frame-Options": True,
}
unauthorized_method_response = _api_gw.MethodResponse(
status_code="401", response_parameters=response_parameters
)
myresource.add_method(
"GET",
_api_gw.LambdaIntegration(
lambda_func,
proxy=False,
request_templates=default_request_template,
integration_responses=[
default_integration_response,
unauthorized_integration_response,
],
),
method_responses=[default_method_response, unauthorized_method_response],
)
本文标签: pythonreturn 401 from lambda nonproxy api gateway and return headersStack Overflow
版权声明:本文标题:python - return 401 from lambda non-proxy api gateway and return headers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744070609a2585813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论