Last active
September 1, 2016 11:49
-
-
Save lennym/0186b9ceb03d4076f26b07720a41d5aa to your computer and use it in GitHub Desktop.
This file contains 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
const express = require('express'); | |
const app = express(); | |
const router = express.Router(); | |
router.get('/foo', (req, res, next) => { | |
res.locals.foo = 'bar'; | |
next(); | |
}); | |
router.get('/bar', (req, res, next) => { | |
res.locals.bar = 'foo'; | |
next(); | |
}); | |
app.use(router); | |
app.use((req, res) => { | |
res.json(res.locals); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment