Skip to content

Set array parameters from a Ruby array #78

@sferik

Description

@sferik

Faraday should allow you to set array parameters using the following syntax:

Faraday.new(:url => 'http://localhost:1234').get do |request|
  request.url('foo', 'bar' => ['baz', 'qux'])
end

Currently, doing this makes the following request:

GET /foo?bar=baz&bar=qux

I propose it should make this request instead, in keeping with Rack:

GET /foo?bar[]=baz&bar[]=qux

Currently, to get this result, you must construct your request like this, which is a bit ugly ugly:

Faraday.new(:url => 'http://localhost:1234').get do |request|
  request.url('foo', 'bar[]' => ['baz', 'qux'])
  #                      ^ eww, gross
end

Discuss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions