Last active
October 1, 2015 02:19
-
-
Save joshgillies/c20d8488059b9f86915a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module['exports'] = function getResource (hook) { | |
var hyperquest = require('hyperquest') | |
var resource = hook.env.resource | |
hyperquest(resource, { method: 'HEAD' }, function getHeaders (err, res) { | |
if (err) { | |
return logAndEnd(err.messsage || err) | |
} | |
var post = hyperquest.post(hook.env.next, { | |
headers: { | |
'content-type': 'application/json', | |
'referrer': hook.req.url | |
} | |
}, function done (err) { | |
logAndEnd(err ? err.messsage || err : JSON.stringify(res.headers)) | |
}) | |
post.end(JSON.stringify({ | |
resource: resource, | |
headers: res.headers | |
})) | |
}) | |
function logAndEnd (message) { | |
console.log(message) | |
hook.res.end(message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment