Create InternalMiddleware system #12

Merged
merged 21 commits into from Oct 11, 2012

1 participant

@arsduo
Owner

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.

@arsduo Merge branch 'refs/heads/ostruct' into middleware
Conflicts:
	changelog.md
	lib/batch_api/version.rb
914ca74
@arsduo arsduo merged commit cdacb18 into master Oct 11, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment