Skip to content

Instantly share code, notes, and snippets.

@acgray
Last active August 29, 2015 14:09
Show Gist options
  • Save acgray/f17a84e10ec236026a74 to your computer and use it in GitHub Desktop.
Save acgray/f17a84e10ec236026a74 to your computer and use it in GitHub Desktop.
http = require('http');
module['exports'] = function echoHttp (hook) {
var options = {
hostname: 'www.telize.com',
port: 80,
path: '/geoip/'+hook.params.ip,
method: 'GET'
}
http.get('http://www.telize.com/geoip/'+hook.params.ip, function(res) {
var body = '';
response.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
hook.res.end(JSON.stringify({
ip: hook.params.ip,
geo: JSON.parse(body)
}));
})
}).on('error', function(e) {
hook.res.end(JSON.stringify({
error: e.message
}))
});
};
module['exports'].schema = {
"ip": {
"type": "string"
}
};
@Marak
Copy link

Marak commented Nov 19, 2014

Errors should now pipe back to the client.

Thanks for trying out the service!

Please let me know if you have any other issues getting your Hook running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment