Skip to content

Instantly share code, notes, and snippets.

@manjeshpv
Created June 9, 2017 04:36
Show Gist options
  • Save manjeshpv/d91aab376989dd7f2b9ef5bbbfcee256 to your computer and use it in GitHub Desktop.
Save manjeshpv/d91aab376989dd7f2b9ef5bbbfcee256 to your computer and use it in GitHub Desktop.
// express.js
app.use((req, res, next) => {
req.v2 = req.get('version') === '2'
return next();
})
app.get('/securedapi', (req, res) => {
if(req.v2)
//new logic
return console.log('new logic');
return console.log('old logic')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment