Skip to content

Instantly share code, notes, and snippets.

@clarkio
Created August 11, 2017 19:39
Show Gist options
  • Save clarkio/21f66b7c8e403078d8e29e0f5663a3d6 to your computer and use it in GitHub Desktop.
Save clarkio/21f66b7c8e403078d8e29e0f5663a3d6 to your computer and use it in GitHub Desktop.
Restify middleware next() blog post code snippets - before changes
server.get('/secure/route',
// My short-circuiting middleware "module"
function checkAuthorization (req, res, next) {
res.send(401, 'Unauthorized');
return next();
},
// My route implementation
function routeAction (req, res, next) {
res.send(200, { data: 'secure data' });
return next();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment