arsduo/batch_api — pull request #12 by arsduo (2012-09-20 18:06:20+00:00)
Title: Create InternalMiddleware system

This pull request refactors the BatchApi gem to use a middleware system to process requests
using mitchellh's middleware gem.

The InternalMiddleware module provides a configurable stack that handles batch requests.
This happens in four parts (described in more detail in internal_middleware.rb):

1) Batch-wide middleware, which can act on the entire set of requests.
2) The processor kicks off the individual operations (currently sequential only).
3) Operation-specific middleware, which act on individual batch ops.
4) The executor, which actually calls onward in the Rack stack, executing the RESTful request.

This system allow users a lot more flexibility in how requests are processed. For instance:
* Decoding the body of JSON responses, making it easier for clients to process them (already included)
* Format the entire response in whatever format you want (will be factored out)
* Add or remove additional components to the operation results (for instance, to surpress output from calls you don't care about, as described in the readme)

No doubt other apps will have other specific needs that this system will address.

*NOTE*: I'd like to refactor the middleware into two stacks (batch and ops) rather than one; this will
be cleaner and more straightforward to work with. (I of course realized this as I wrote this PR.) That will
happen as a separate request.