This enables the use of `#in_parallel` without manually passing in a
parallel manager instance.
If the adapter you're using has a parallel manager, it will work as
expected. If it doesn't, it'll work as normal sequential requests.
Old behavior:
# init connection with some defaults:
conn = Faraday.new :params => {...}, :request => {...}
conn.get('/') do |request|
request.params = {...} # params got merged with defaults
request.options = {...} # options got deep-merged with defaults
end
New behavior:
conn.get('/', {...}) do |request|
request.params.update(...) # merge with existing params
request.params = {...} # replace all existing params
request.options[:proxy][:user] = "..." # add extra request options:
request.options = {...} # replace all existing options
end
Pros of the new behavior are consistency, ability to completely override
parameters per-request. Cons are breaking backwards-compatibility.
This is backwards-incompatible.
The signature for these methods was:
(url, headers)
Now it is:
(url, params, headers)
The params hash adds values to the query string of the request.
Closes#88
Yes, named blocks (Procs) in methods are slow in Ruby. This is because
of unfortunate performance penalty of instantiating and
garbage-collecting these Proc objects, which happens even if we never
use or even pass a block to the method. Certain methods in Faraday were
optimized to avoid named blocks.
This removes such optimizations. The rationale is that the performance
penalty of named blocks is negligible to the overhead of HTTP requests
over the network.
Allows 3rd-party libraries to register named shortcuts to resolve to
fully qualified constant names for specific middleware.
Usage:
Faraday.register_middleware :aloha => MyModule::Aloha
Faraday.register_middleware :response, :boom => MyModule::Boom
Faraday.register_middleware :lazy => lambda { MyModule::LazyLoaded }
Those shortcuts are then available in Builder:
builder.use :aloha
builder.response :boom
This is a potentially breaking change for 3rd party code that relies on
env[:url] being specifically Addressable. After this change all urls are
passed around as instances of URI::HTTP.
This allows:
Faraday.new {|f| f.url_prefix = '...' }
Backwards compatibility is kept for the most part because main Builder
methods `use`, `request`, `response` and `adapter` are already forwarded
from Connection:
# will function as before:
Faraday.new {|f| f.adapter :net_http }