sdk-javascript/lib/bindings/http/binary_0_1.js

30 lines
686 B
JavaScript

var axios = require("axios");
function HTTPBinary(configuration){
this.config = configuration;
this.config["headers"] = {
"Content-Type":"application/cloudevents+json; charset=utf-8"
};
}
HTTPBinary.prototype.emit = function(cloudevent){
// Create new request object
var _config = JSON.parse(JSON.stringify(this.config));
// Always set stuff in _config
var _headers = _config["headers"];
_headers["Content-Type"] = cloudevent.getContenttype();
_headers["CE-EventType"] = cloudevent.getType();
// Set the cloudevent payload
_config["data"] = cloudevent.format();
// Return the Promise
return axios.request(_config);
};
module.exports = HTTPBinary;