ZijianHe / koa-router

Router middleware for koa.
MIT License
4.85k stars 408 forks source link

path of router.use() method can be a RegExp? #220

Open XuJinNet opened 8 years ago

XuJinNet commented 8 years ago

i `m set a regexp to router.use(), got a error:

Error: (.*): middleware must be a function, not object at Layer. (...\node_modules\koa-router\lib\layer.js:38:13) at Array.forEach (native) at new Layer (...\node_modules\koa-router\lib\layer.js:35:14) at Router.register (...\node_modules\koa-router\lib\router.js:503:15) at Router.use (...\node_modules\koa-router\lib\router.js:256:12)

alexmingoia commented 8 years ago

Regular expressions aren't supported. There are a number of features that would need to be slightly refactored to support regular expressions (nested routes and parameter matching to name a few).

cb1kenobi commented 8 years ago

I ran just ran into this. +1 to supporting this feature someday.