Some syntax sugar. Would be cool, if express would parse RegEx’s as a part of routing paths.
Example:
"/page/:page([0-9])"
"/skin/:direction([a-z])?/:resolution([0-9])?/:username"
Eveything in the braces should be parsed as a RegEx. That way more complex, but sweetend, paths could be built. 🙂
I know, that you can pass in RegEx’s as a path, but then you’ll end up with req.params
as an array.
Yeah or No? Maybe I’ll make a PR.
Hmm.
Isn’t
app.param
used for this? Of courseapp.param
callbacks will execute for each route but if you want it only for a specific route, just add another middleware before you main callback and if the parameter doesn’t match your regex runnext('route')
.