admin管理员组文章数量:1401176
I'm trying to return a header from a lambda, it's returned as "<;limit=0>; rel=\"next\""
instead of <;limit=0>; rel="next"
.
And also when I don't return the header, I still see it as ""
.
This is my cdk:
_api_gw.MethodResponse(
status_code="200", response_parameters={"method.response.header.Link": True}
)
integration_response = _api_gw.IntegrationResponse(
status_code="200",
response_parameters=response_integration_parameters,
response_templates={
"application/json": """
#set($inputRoot = $input.path('$'))
## Map headers only if exist ##
#set($link = $input.json('$.Link'))
#if($link != "")
#set($context.responseOverride.header.Link = $link)
#end
## Clean JSON body (exclude headers) ##
{
"data": $input.json('$.data'),
}
"""
},
)
default_request_template = {
"application/json": '{ "method": "$context.httpMethod", "body" : "$util.escapeJavaScript("$input.json(\'$\')")", "headers": { #foreach($param in $input.params().header.keySet()) "$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end #end }, "queryParams": { #foreach($param in $input.params().querystring.keySet()) "$param": "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end #end }, "pathParams": { #foreach($param in $input.params().path.keySet()) "$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end #end }}'
}
resource.add_method(
"GET",
_api_gw.LambdaIntegration(
my_lambda,
proxy=False,
request_templates=default_request_template,
integration_responses=[integration_response],
),
method_responses=[
_api_gw.MethodResponse(
status_code="200", response_parameters={"method.response.header.Link": True}
)
],
)
本文标签: pythonreturn header without quotes in aws lambdaremove header if emptyStack Overflow
版权声明:本文标题:python - return header without quotes in aws lambda + remove header if empty - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744263497a2597831.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论