Skip to content

Instantly share code, notes, and snippets.

@keis
Created March 3, 2015 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keis/f948ff8371c9b8d5a104 to your computer and use it in GitHub Desktop.
Save keis/f948ff8371c9b8d5a104 to your computer and use it in GitHub Desktop.
function capture(regex) {
return function (req, res, next, val, name) {
var capture;
console.log("name", name, "val", val);
if (capture = regex.exec(val)) {
req.params[name] = capture;
next();
} else {
next('route');
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment