@lambda-middleware/http-header-normalizer
v1.0.3
Published
Middleware for AWS lambdas that normalizes headers to lower-case
Downloads
2
Maintainers
Readme
@lambda-middleware/http-header-normalizer
Middleware for AWS lambdas that normalizes headers to lower-case and referer to referrer and vice-versa. If you are used to the corresponding middy middleware, please note that this middleware acts differently as it does not hold an exception list and converts everything to lower-case.
Lambda middleware
This middleware is part of the lambda middleware series. It can be used independently.
Usage
import { httpHeaderNormalizer } from "@lambda-middleware/http-header-normalizer";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
// This is your AWS handler
async function helloWorld({
headers,
}: APIGatewayProxyEvent): APIGatewayProxyResult {
return {
body: JSON.stringify({
msg: headers["custom-header"],
}),
statusCode: 200,
};
}
// Wrap the handler with the middleware
export const handler = httpHeaderNormalizer()(helloWorld);