Skip to content

Instantly share code, notes, and snippets.

@RX14
Created February 14, 2015 18:20
Show Gist options
  • Save RX14/f916a49834a9347b40f3 to your computer and use it in GitHub Desktop.
Save RX14/f916a49834a9347b40f3 to your computer and use it in GitHub Desktop.
console.log('Loading event');
var url = require("url");
var http = require("http");
exports.handler = function(event, context) {
var body = JSON.stringify(event.body);
event.handlers.forEach(function(handler) {
var thisURL = url.parse(handler.url);
var options = {
hostname: thisURL.hostname,
port: thisURL.port || 80,
path: thisURL.path,
method: handler.method,
headers: {
'Content-Type': 'application/json',
'Content-Length': body.length
}
};
var req = http.request(options, function(res) {
console.log("STATUS: " + res.statusCode);
res.setEncoding("utf8");
res.on("end", function() {
console.log("FINISH");
});
res.resume();
});
req.on('error', function(e) {
console.log('ERROR: ' + e.message);
});
req.write(body);
req.end();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment