includeos / acorn

Acorn Web Server Appliance, built with IncludeOS
Apache License 2.0
93 stars 13 forks source link

Regex route match should preserve matched groups #9

Closed alfreb closed 8 years ago

alfreb commented 8 years ago

Eventually, we want e.g. /api/users/:id/profile to result in capturing id into a key-value data structure, so we can e.g. do req.route("id") => 52 for the URI /api/users/52/profile.

While we don't have the regex-from-route-path-generator we know it's going to use regex capture groups, so we can still preserve these. We can now do e.g.: /api/users/(\d+)/profile, and provide the resulting matches in a datastructure. We don't have key names yet, so it will be req.route_part(0) => 52 for the URI /api/users/52/profile.

AndreasAakesson commented 8 years ago

Added in #37