Skip to content

Instantly share code, notes, and snippets.

@nikolasleblanc
Last active August 29, 2015 14:21
Show Gist options
  • Save nikolasleblanc/3e3940c8e7f558a00945 to your computer and use it in GitHub Desktop.
Save nikolasleblanc/3e3940c8e7f558a00945 to your computer and use it in GitHub Desktop.
Express middleware with additional arguments
function tryThis(myString) {
return function(req, res, next) {
req.heyThere = myString; // should be set to "OH YEAH!"
next();
};
}
app.get("/", tryThis("OH YEAH!"), function(req, res) {
console.log(req.heyThere);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment