25 lines
518 B
JavaScript
25 lines
518 B
JavaScript
var axios = require("axios");
|
|
|
|
function HTTPStructured(configuration){
|
|
this.config = configuration;
|
|
|
|
this.config['headers'] = {
|
|
'Content-Type':'application/cloudevents+json; charset=utf-8'
|
|
};
|
|
}
|
|
|
|
HTTPStructured.prototype.emit = function(cloudevent){
|
|
|
|
// Create new request object
|
|
var _config = JSON.parse(JSON.stringify(this.config));
|
|
|
|
// Set the cloudevent payload
|
|
_config['data'] = cloudevent.format();
|
|
|
|
// Return the Promise
|
|
return axios.request(_config);
|
|
}
|
|
|
|
module.exports = HTTPStructured;
|
|
|