Using the commons
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
c37b31fc3b
commit
733476f4a1
|
@ -1,4 +1,5 @@
|
||||||
const Constants = require("./constants.js");
|
const Constants = require("./constants.js");
|
||||||
|
const Commons = require("./commons.js");
|
||||||
const Cloudevent = require("../../cloudevent.js");
|
const Cloudevent = require("../../cloudevent.js");
|
||||||
const Spec02 = require("../../specs/spec_0_2.js");
|
const Spec02 = require("../../specs/spec_0_2.js");
|
||||||
|
|
||||||
|
@ -51,16 +52,6 @@ function validate_args(payload, attributes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanity(headers) {
|
|
||||||
var sanity_headers = JSON.parse(JSON.stringify(headers));
|
|
||||||
|
|
||||||
for(header in sanity_headers){
|
|
||||||
sanity_headers[header.toLowerCase()] = sanity_headers[header];
|
|
||||||
}
|
|
||||||
|
|
||||||
return sanity_headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Receiver(configuration) {
|
function Receiver(configuration) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +61,7 @@ Receiver.prototype.check = function(payload, headers) {
|
||||||
validate_args(payload, headers);
|
validate_args(payload, headers);
|
||||||
|
|
||||||
// Clone and low case all headers names
|
// Clone and low case all headers names
|
||||||
var sanity_headers = sanity(headers);
|
var sanity_headers = Commons.sanity_and_clone(headers);
|
||||||
|
|
||||||
// Validation Level 1
|
// Validation Level 1
|
||||||
if(!allowed_content_types
|
if(!allowed_content_types
|
||||||
|
@ -98,7 +89,7 @@ Receiver.prototype.parse = function(payload, headers) {
|
||||||
this.check(payload, headers);
|
this.check(payload, headers);
|
||||||
|
|
||||||
// Clone and low case all headers names
|
// Clone and low case all headers names
|
||||||
var sanity_headers = sanity(headers);
|
var sanity_headers = Commons.sanity_and_clone(headers);
|
||||||
|
|
||||||
var cloudevent = new Cloudevent(Spec02);
|
var cloudevent = new Cloudevent(Spec02);
|
||||||
for(header in setter_reflections) {
|
for(header in setter_reflections) {
|
||||||
|
|
Loading…
Reference in New Issue