Z-Wave-Me/home-automation — pull request #35 by peaches (2014-05-06 05:58:33+00:00)
Title: Adding a router layer to web requests

This is hopefully to simplify future additions of routes to the API.
If we had a more comprehensive set of routes, it may make sense to
switch to a library for route handling. Otherwise this is a simple
replacement that aims to keep backwards compatibility with the
existing routes.

At the moment, the router supports both the simple paths and the
patterned paths. A simple match returns:

{
handler: handlerFunc,
params: []
}

On the other hand, the patterned matcher returns the handler function
and the matched URL parameters, so if we define a url as:

/foo/:param1/bar/:param2

The matched route for /foo/abcde/bar/hijkl would be:

{
handler: handlerFunc,
params: ["abcde", "hijkl"]
}