opened
dschinkel
username_0
So I'm trying to create a route that'll take /people/locationId:12345

I'm not creating a route for something like people/10/locations/20 which would look like this:

/people/:id/locations/:id

so how would I be able to do the first.  The purpose of it is to allow people to specify filtering on fields right in the URI as opposed to something like /people?locationId:12345
How to Specify params in the URI via Name
issue
created
alexmingoia
username_1
Koa-router used the [path-to-regexp](https://github.com/pillarjs/path-to-regexp) module to translate path patterns into regular expressions.

The pattern string you want is `/people/:locationId(locationId:\\d+)`. That matches `/people/locationId:12345` and populates `ctx.params.locationId` with `locationId:12345`.

As far as I know, you cannot get just `12345` out of the parameter value without middleware. I would recommend creating your own query parsing middleware mounted to the router using `router.use()` that inspects `ctx.params.locationId` and removes the `locationId:` prefix from the value for subsequent middleware.
comment
closed
alexmingoia
username_1
issue