Skip to content

Instantly share code, notes, and snippets.

@FrankGrimm
Forked from alhafoudh/handler.js
Created November 22, 2014 20:20
Show Gist options
  • Save FrankGrimm/ff5f0e763c83f20369c3 to your computer and use it in GitHub Desktop.
Save FrankGrimm/ff5f0e763c83f20369c3 to your computer and use it in GitHub Desktop.
var http_on_error = function http_on_error(context) {
return function(e) {
console.log("Got error: " + e.message);
context.done(e.message); // I need to pass-in the context variable
};
};
var http_on_success = function http_on_error(context) {
return function(e) {
console.log("Got response: " + res.statusCode);
context.done(null); // I need to pass-in the context variable
};
};
exports.handler = function(event, context) {
var success_handler = http_on_success(context);
var error_handler = http_on_error(context);
for (var i in event.Records) {
var record = event.Records[i];
console.log("Processing record");
var data = new Buffer(record.kinesis.data, 'base64').toString();
console.log("Input data: " + data);
var http = require('http');
http
.get(data, success_handler)
.on('error', error_handler);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment