Mapping Lambda output to API Gateway header

前端 未结 5 660
失恋的感觉
失恋的感觉 2021-01-31 20:02

I\'m trying to map the JSON output from a Lambda function to the header of an API Gateway call. As an example here, we can consider a redirect scenario. So I\'d like to add a

相关标签:
5条回答
  • 2021-01-31 20:27

    Actually, it seems you can access to all the headers provided by the original response (if it contains a Content-type, then you can type : integration.response.header.Content-type). However, I have not find out any way to add a new header (except statically).

    0 讨论(0)
  • 2021-01-31 20:34

    From the AWS developer forums today (25 September 2015) this isn't possible yet, but may be coming in the future:

    API Gateway does not currently support mapping from the integration response body to the response headers, but we are looking to add support for this in the future.

    Forum post here

    Edit December 2015: Feature as been added according to a post by an AWS employee in the thread linked above. Thanks to Peter Fox for pointing that out.

    0 讨论(0)
  • 2021-01-31 20:36

    I know it has been a while since this was asked but you can now set:

    integration.response.header.Location (note Uppercase L in Location) in Mapping value if you are setting it in response headers.

    Example

    0 讨论(0)
  • 2021-01-31 20:45

    Today (12th, November, 2015), I was looking for how to pass the Location header from my backend API to a Location header in integration response.

    This configuration worked and I could get Location header from backend api:

    Looks like the solution proposed by Tobias is possible currently. However, the Location header points to the backend API and this is not what we want. I'll try to find a solution for this and post it here.

    0 讨论(0)
  • 2021-01-31 20:48

    As of today (January 2016), it works by simply specifying integration.response.body.Location in your case.

    0 讨论(0)
提交回复
热议问题