Skip to content

Instantly share code, notes, and snippets.

@ufocoder
Created October 31, 2018 12:09
Show Gist options
  • Select an option

  • Save ufocoder/2cd3537aa80a57f550819ac0749e71b6 to your computer and use it in GitHub Desktop.

Select an option

Save ufocoder/2cd3537aa80a57f550819ac0749e71b6 to your computer and use it in GitHub Desktop.
router.get(url, function (req, res) {
function handleSuccess (file) {
res.writeHead(200, { "Content-Type": "application/octet-stream" });
res.write(file);
res.end();
}
function handleError (err) {
res.writeHead(404);
res.end();
}
const callback = higherOrderNodeCallback(handleSuccess, handleError);
readFile(filePath, callback);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment