Sha256: d4d6774e16ed0ec6f2b43f4bba44ee6ea1852cb8419980fbd19b8e5c9f6b8a18

Contents?: true

Size: 495 Bytes

Versions: 17

Compression:

Stored size: 495 Bytes

Contents

module Attune
  # Faraday 0.8 can't make resuests like /?ids=123&ids=456 and forces the form
  # /?ids[]=123&ids[]=456 (this is fixed in faraday 0.9)
  #
  # Fortunately faraday's middleware is quite powerful. This just strips the
  # array syntax from the request.
  class ParamFlattener < Faraday::Middleware
    def call(env)
      url = env[:url]

      # replaces ?foo[]=123 with ?foo=123
      url.query = url.query.gsub('%5B%5D', '') if url.query

      @app.call(env)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
attune-1.0.21 lib/attune/param_flattener.rb
attune-1.0.20 lib/attune/param_flattener.rb
attune-1.0.19 lib/attune/param_flattener.rb
attune-1.0.18 lib/attune/param_flattener.rb
attune-1.0.17 lib/attune/param_flattener.rb
attune-1.0.16 lib/attune/param_flattener.rb
attune-1.0.15 lib/attune/param_flattener.rb
attune-1.0.14 lib/attune/param_flattener.rb
attune-1.0.13 lib/attune/param_flattener.rb
attune-1.0.12 lib/attune/param_flattener.rb
attune-1.0.11 lib/attune/param_flattener.rb
attune-1.0.10 lib/attune/param_flattener.rb
attune-1.0.9 lib/attune/param_flattener.rb
attune-1.0.8 lib/attune/param_flattener.rb
attune-1.0.7 lib/attune/param_flattener.rb
attune-1.0.6 lib/attune/param_flattener.rb
attune-1.0.5 lib/attune/param_flattener.rb