Created
December 21, 2011 20:57
-
-
Save addisonj/1507669 to your computer and use it in GitHub Desktop.
normalize a response
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
// with normalizing middleware | |
app.use(normalizeResponse) | |
app.get('/account', common, UserRead) | |
function UserRead(req, res, next) { | |
// do stuff and attach it onto the res object | |
// call next() when done | |
next() | |
} | |
function normalizeResponse(req, res) { | |
//gets called last by every resquest | |
// does what it needs and then | |
res.json(res.response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment