Skip to content

Commit b5a6673

Browse files
authored
lib: destruct contants in http/unmarshaller.js (#152)
Signed-off-by: Daniel Bevenius <[email protected]>
1 parent 8b67d36 commit b5a6673

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/bindings/http/unmarshaller.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
const Constants = require("./constants.js");
1+
const {
2+
HEADER_CONTENT_TYPE,
3+
MIME_CE,
4+
MIME_CE_JSON,
5+
MIME_JSON,
6+
MIME_OCTET_STREAM
7+
} = require("./constants.js");
28
const Commons = require("./commons.js");
39

410
const STRUCTURED = "structured";
511
const BINARY = "binary";
612

713
const allowedBinaryContentTypes = [
8-
Constants.MIME_JSON,
9-
Constants.MIME_OCTET_STREAM
14+
MIME_JSON,
15+
MIME_OCTET_STREAM
1016
];
1117

1218
const allowedStructuredContentTypes = [
13-
Constants.MIME_CE_JSON
19+
MIME_CE_JSON
1420
];
1521

1622
// Is it binary or structured?
1723
function resolveBindingName(payload, headers) {
1824
const contentType =
19-
Commons.sanityContentType(headers[Constants.HEADER_CONTENT_TYPE]);
25+
Commons.sanityContentType(headers[HEADER_CONTENT_TYPE]);
2026

21-
if (contentType.startsWith(Constants.MIME_CE)) {
27+
if (contentType.startsWith(MIME_CE)) {
2228
// Structured
2329
if (allowedStructuredContentTypes.includes(contentType)) {
2430
return STRUCTURED;
@@ -54,7 +60,7 @@ class Unmarshaller {
5460

5561
// Validation level 1
5662
const sanityHeaders = Commons.sanityAndClone(headers);
57-
if (!sanityHeaders[Constants.HEADER_CONTENT_TYPE]) {
63+
if (!sanityHeaders[HEADER_CONTENT_TYPE]) {
5864
throw new TypeError("content-type header not found");
5965
}
6066

0 commit comments

Comments
 (0)