From 6de756d1023a4688855a586b90ed65ad12548a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 11 Jun 2019 12:37:49 -0300 Subject: [PATCH] New contants + usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- lib/bindings/http/constants.js | 3 +++ lib/bindings/http/unmarshaller_0_2.js | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bindings/http/constants.js b/lib/bindings/http/constants.js index 7be8dfc..fea4a2a 100644 --- a/lib/bindings/http/constants.js +++ b/lib/bindings/http/constants.js @@ -1,6 +1,9 @@ // Commons module.exports = { + CHARSET_DEFAULT : "utf-8", + MIME_JSON : "application/json", + MIME_CE : "application/cloudevents", MIME_CE_JSON : "application/cloudevents+json", HEADER_CONTENT_TYPE : "content-type" diff --git a/lib/bindings/http/unmarshaller_0_2.js b/lib/bindings/http/unmarshaller_0_2.js index 49fc02f..10b00fe 100644 --- a/lib/bindings/http/unmarshaller_0_2.js +++ b/lib/bindings/http/unmarshaller_0_2.js @@ -3,8 +3,6 @@ var JSONParser = require("../../formats/json/parser.js"); const Constants = require("./constants.js"); -const ce_structured_content_type = "application/cloudevents"; - const structured = "structured"; const binary = "binary"; @@ -37,9 +35,9 @@ function validate_args(payload, headers) { function resolve_binding_name(payload, headers) { var contentType = headers[Constants.HEADER_CONTENT_TYPE]; - if(contentType.startsWith(ce_structured_content_type)){ + if(contentType.startsWith(Constants.MIME_CE)){ // Structured - console.log(allowed_structured_content_types); + if(allowed_structured_content_types.includes(contentType)){ return structured; } else {