technoweenie/faraday — Issue #88: Connection#get to accept query parameters?
Author: mislav
Created: 2011-10-16 22:01:55+00:00
State: open

One of my biggest gripes with Faraday is that it's awkward to pass in parameters to `get()`. Just look at how easy it is with `post`:

~~~ ruby
conn.post "/create", name: "Mislav"
~~~

And now `get`:

~~~ ruby
conn.get "/search" do |req|
req.params = {name: "Mislav"}
end
~~~

That's a lot of work for something simple. I want the 2nd argument for `get` to match `post`. Trouble is, the 2nd argument now is request headers, and that means breaking backwards compatibility. There's no reliable way to detect whether some hash should be request headers or query values.

One thing *against* changing this is that 2nd argument to `post` is really called `body`, which indicates it can take anything that represents a body for the request. We accept a hash and then encode it in middleware, but that's kind of a feature we did there. The argument really is `body`, and if `get` accepts query params as 2nd argument that would definitely not be called `body` since GET doesn't have a body.

What do you say guys? Break backwards compat for a noble cause? Not worth it? Speak up.

(Changing `get` arguments would also mean changing `head` and `delete` to match it.)