Last active
August 29, 2015 14:21
-
-
Save sepulworld/caee93305dbb27e90b7f to your computer and use it in GitHub Desktop.
warm_cdn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
exports.handler = function(event, context) { | |
var responses = {}, | |
count = 0; | |
for (var key in event ) { | |
console.log('start request to ' + event[key]); | |
http.get(event[key], function(res) { | |
console.log("Got response: " + res.statusCode); | |
count++; | |
if (count == Object.keys(event).length) { | |
callback(responses, context); | |
} | |
console.log(count) | |
}).on('error', function(e) { | |
console.log("Got error: " + e.message); | |
count++; | |
if (count == Object.keys(event).length) { | |
callback(responses, context); | |
} | |
}); | |
console.log('end request to ' + event[key]); | |
} | |
function callback(responses, context) { | |
context.done() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment