Z-Wave-Me/home-automation — pull request #31 by peaches (2014-05-03 09:27:31+00:00)
Title: Adding a router layer to web requests

NOTE: I'm not sure what the coding standard is, let me know so
I can change my stuff.

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"]
}