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 Antwort
0
Akzeptierte Antwort

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
EXPERTE
Uri
beantwortet vor 4 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen