Return Count from Lambda into the "Response Header" of the API

0

A customer is using API Gateway to return information via Lambda. However, they would like to put a count from Lambda into the "Response Header" of the API, which is returned to the requester, instead of in the body of the response.

In API Gateway how can I take the response from Lambda and map the "count" field into the header of the HTTP response?

1개 답변
0
수락된 답변

If you return the count in a header from the Lambda function you can just reference it using integration.response.header.header-name.

To return a header from the Lambda function just return something like this:

{
    "statusCode": 200,
    "headers": {
        "header1Name": "header1Value",
        "header2Name": "header2Value",
    },
    "body": "...",
}

For more information see here. You will see that it describes that only headers from the backend can be mapped to headers in the response.

profile pictureAWS
전문가
Uri
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠