koajs/route — pull request #21 by travisjeffery (2014-10-15 05:14:15+00:00)
Title: Add opts argument to routes

Issue I'm currently hitting is:

I have a set of routes that have the same prefix, e.g.

```
GET /:owner/:project
GET /:owner/:project/owner
POST /:owner/:project/collaborators
```

etc. and I want a couple of middleware fns to get/set this.project and this.account by the :owner and :project parsed from the path.

```
koa()
.use(route.all('/:owner/:project', setProject))
.use(route.all('/:owner/:project', setOwner))
.use(route.post('/:owner/:project/owner', addCollaborator))
...
```

problem is that koa-route uses path-to-regexp and by default, path-to-regexp matches from the end. so those middleware fns will only match the first route of my examples.

so we need a way to pass options to path-to-regexp and that's what this pr is for. so that you can configure how the route you're making will behave/be parsed.

will this pr you'll be able to do:

```
koa()
.use(route.all('/:owner/:project', setProject, { end: false }))
.use(route.all('/:owner/:project', setOwner, { end: false }))
.use(route.post('/:owner/:project/owner', addCollaborator))
...
```
and all those examples will work. I've added a test for this as well.