Open newbaluku opened 4 years ago
You can use a transformation (https://github.com/dougmoscrop/serverless-http/blob/master/docs/ADVANCED.md#transformations) to basically add anything you want to the request, does that work for you?
Thanks for the quick response. if I just want to add the context.awsRequestId (Lambda requestId) to all response's header from my endpoints.
Is there an existing way to do it?
I tried this according to the doc: module.exports.handler = serverless(app, { requestId: 'X-ReqId', });
but didn't find any trace of the requestId.
thank you @dougmoscrop for your reference. I was able to solve this with the following:
export interface Context {
awsRequestId: string;
}
export const handler = serverless(app, {
request(request: Request, event: any, context: Context) {
request.requestId = context.awsRequestId || "";
},
});
besides x-amzn-requestid, how can I also get the Lambda requestId from my endpoints?