technoweenie/faraday — pull request #207 by technoweenie (2012-10-28 20:50:26+00:00)
Title: Callback builder

Today, I [refactored things](https://github.com/technoweenie/faraday/compare/64892e2e9c7d93712cbb2636ff1a8064ceffcf05...77d7546d6d626b91086f427c56bc2cdd951353b3) so that a Builder is responsible for taking a request and turning it into a response. It's been renamed to RackBuilder because it uses a chain of middleware objects that pass an Env through them.

This PR adds a CallbackBuilder:

* No more Env object. Let's just pass requests and responses around.
* The request/response callback system is simpler. No more chaining. Here's a [single class](https://github.com/technoweenie/faraday/blob/6f376805fbec933ef233d731aba91305842ec0ee/test/callback_builder_test.rb#L5-13) that can affect the request and response objects.
* [Streaming is built-in](https://github.com/technoweenie/faraday/blob/6f376805fbec933ef233d731aba91305842ec0ee/test/callback_builder_test.rb#L25-56) (taking some cues from #156).
* There is only one adapter, and it can be swapped at any time.
* No more array middleware modifications. I think people only used it to swap adapters. I hope :)

This breaks all adapters and middleware. I am sorry. I'm hoping that the changes are good enough that people don't mind. Even if we make CallbackBuilder default, you should be able to [keep passing RackBuilder](https://github.com/technoweenie/faraday/blob/6f376805fbec933ef233d731aba91305842ec0ee/lib/faraday/options.rb#L140-142) to keep the legacy builder.

My plan:

* Faraday 0.8.x will be the last versions that support RackBuilder.
* Faraday 0.9.x will support CallbackBuilder by default, but will allow the legacy behavior. I want to make it as easy as possible on Faraday users.
* Faraday 1.0 will lose all deprecated bits (auto loading, Env class, RackBuilder).
* Also, I really would love to have a better name than CallbackBuilder :)
* Eradicate all references to the Env object.

If you have existing middleware that won't work with this setup, please give me some specific examples.

/cc @mislav @sferik @eric @pengwynn @bmaddy @pezra @paul @avdi @remiprev

(anyone here is either a big part of Faraday, has given me relevant feedback about it, or has some interest in the middleware spec)