繁体   English   中英

返回标题内容 - API Gateway + AWS Lambda

[英]Returning header content - API Gateway + AWS Lambda

我正在开发一个POST lambda函数。 我想在标题中返回“位置”。 所以我配置API网关,如下所示:

API网关配置

当我调用API时,我正在接收标题中的“Location”正确,但我仍然在返回消息时收到它。 往下看:

[ 返回地点[2]

我的python代码:

def os_create_subscription (event, context):
    customer_id = event["customer-id"]
    subscription_id = 12345
    header_location = ("/customers/%s/subscriptions/%d" % (customer_id, subscription_id))
    result = {"Location": header_location}
    return result

所以我想将标题放在标题中。 反正有没有这样做?

来自响应主体的标头映射最近被添加到API网关。 您可以在我们的文档中查看示例。

您的映射应该是: integration.response.body.Location

编辑:误读道歉。 要从响应正文中删除位置,您需要具有空JSON正文的映射模板。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM