diff --git a/lib/bindings/http/unmarshaller.js b/lib/bindings/http/unmarshaller.js index d52164a..db79a8d 100644 --- a/lib/bindings/http/unmarshaller.js +++ b/lib/bindings/http/unmarshaller.js @@ -1,24 +1,30 @@ -const Constants = require("./constants.js"); +const { + HEADER_CONTENT_TYPE, + MIME_CE, + MIME_CE_JSON, + MIME_JSON, + MIME_OCTET_STREAM +} = require("./constants.js"); const Commons = require("./commons.js"); const STRUCTURED = "structured"; const BINARY = "binary"; const allowedBinaryContentTypes = [ - Constants.MIME_JSON, - Constants.MIME_OCTET_STREAM + MIME_JSON, + MIME_OCTET_STREAM ]; const allowedStructuredContentTypes = [ - Constants.MIME_CE_JSON + MIME_CE_JSON ]; // Is it binary or structured? function resolveBindingName(payload, headers) { const contentType = - Commons.sanityContentType(headers[Constants.HEADER_CONTENT_TYPE]); + Commons.sanityContentType(headers[HEADER_CONTENT_TYPE]); - if (contentType.startsWith(Constants.MIME_CE)) { + if (contentType.startsWith(MIME_CE)) { // Structured if (allowedStructuredContentTypes.includes(contentType)) { return STRUCTURED; @@ -54,7 +60,7 @@ class Unmarshaller { // Validation level 1 const sanityHeaders = Commons.sanityAndClone(headers); - if (!sanityHeaders[Constants.HEADER_CONTENT_TYPE]) { + if (!sanityHeaders[HEADER_CONTENT_TYPE]) { throw new TypeError("content-type header not found"); }