/*made by Miguel Rodrigues @ KBZ miguel.rodrigues@knowledgebiz.pt*/
//httpRequest to send Notification by HTTP Request
var http = require("http");
module.exports.sendHttpRequest = function (hostname, port, path, method, notification) {
/*
var options = {
hostname: 'teste.proxy.beeceptor.com',
port: 80,
path: '/my/api/path',
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
*/
var options = {
hostname: hostname,
port: port,
path: path,
method: method,
headers: {
'Content-Type': 'application/json',
}
};
var req = http.request(options, function(res) {
console.log('Status: ' + res.statusCode);
console.log('Headers: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (body) {
console.log('Body: ' + body);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write(notification);
req.end();
}