@middy/http-header-normalizer 4.0.0-alpha.4 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -53
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -36,59 +36,6 @@
|
|
|
36
36
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/http-header-normalizer">https://middy.js.org/docs/middlewares/http-header-normalizer</a></p>
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
-
This middleware normalizes HTTP header names to their canonical format. Very useful if clients are
|
|
40
|
-
not using the canonical names of header (e.g. `content-type` as opposed to `Content-Type`).
|
|
41
|
-
|
|
42
|
-
API Gateway does not perform any normalization, so the headers are propagated to Lambda
|
|
43
|
-
exactly as they were sent by the client.
|
|
44
|
-
|
|
45
|
-
Other middlewares like [`jsonBodyParser`](#jsonbodyparser) or [`urlEncodeBodyParser`](#urlencodebodyparser)
|
|
46
|
-
will rely on headers to be in the canonical format, so if you want to support non-normalized headers in your
|
|
47
|
-
app you have to use this middleware before those ones.
|
|
48
|
-
|
|
49
|
-
This middleware will copy the original headers in `event.rawHeaders`.
|
|
50
|
-
|
|
51
|
-
## Install
|
|
52
|
-
|
|
53
|
-
To install this middleware you can use NPM:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm install --save @middy/http-header-normalizer
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## Options
|
|
61
|
-
|
|
62
|
-
- `normalizeHeaderKey` (function): a function that accepts an header name as a parameter and returns its
|
|
63
|
-
canonical representation.
|
|
64
|
-
- `canonical` (boolean) (default `false`): if true, modifies the headers to canonical format, otherwise the headers are normalized to lowercase
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Sample usage
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
import middy from '@middy/core'
|
|
71
|
-
import httpHeaderNormalizer from '@middy/http-header-normalizer'
|
|
72
|
-
|
|
73
|
-
const handler = middy((event, context) => {
|
|
74
|
-
return {}
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
handler
|
|
78
|
-
.use(httpHeaderNormalizer({canonical: true}))
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
## Middy documentation and examples
|
|
83
|
-
|
|
84
|
-
For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## Contributing
|
|
88
|
-
|
|
89
|
-
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
90
|
-
|
|
91
|
-
|
|
92
39
|
## License
|
|
93
40
|
|
|
94
41
|
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-header-normalizer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Http header normalizer middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"url": "https://github.com/middyjs/middy/issues"
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://middy.js.org",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c5ece2bfbb0d607dcdea5685bf194a6cc19acc8d",
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@middy/core": "4.0.
|
|
68
|
+
"@middy/core": "4.0.1"
|
|
69
69
|
}
|
|
70
70
|
}
|