puppetlabs/puppetdb — pull request #284 by nicklewis (2012-09-18 01:01:21+00:00)
Title: Standardize HTTP handlers

This extracts a few middleware functions for checking HTTP requests, and then uses them + moustache to build a pattern for the HTTP handlers. Every app now defines a moustache app `routes`, with the simplest mapping from route to handler. This app is then wrapped with whatever validation is appropriate, as eg. `facts-app`.

All nested routes are now handled by the apps themselves, with the top-level `v1` and `experimental` apps simply passing along the rest of the route, having no knowledge of the nested apps themselves. This simplifies the apps significantly, and will hopefully let us use more reusable code around building and testing them in future.