Provides access to components of the HTTP request being handled.
Since Lambda Wrapper v2, the RequestService instance is no longer passed as an argument to your wrapped handler, and must be obtained via di.
import lambdaWrapper, { RequestService } from '@comicrelief/lambda-wrapper';
export default lambdaWrapper.wrap(async (di) => {
const request = di.get(RequestService);
// get the 'name' request parameter, defaulting to 'world' if not set
const name = request.get('name', 'world');
return ResponseModel.generate({}, 200, `Hello, ${name}`);
});getAllHeadersreturns an object containing all HTTP headers, with all keys lowercasegetHeaderreturns the value of a single HTTP headergetAuthorizationTokenextracts a Bearer token from theAuthorizationheader
For requests that submit data in their body (POST, PATCH, PUT),
getAllparses the body according to theContent-Typeheadergetfetches a single value from the body
For other request methods without a body (GET, HEAD, DELETE),
getAllreturns an object containing all query string parametersgetfetches a single query string parameter
For all requests,
getPathParameterfetches a path parameter value
Some limited information about the client making the request is available.
getIpreturns the request's source IP addressgetUserBrowserAndDevicereturns user agent details