Sha256: d0f856c57aebdd232e462547c46f37ca0d70814eaa220c64ca72ed8561d4893f
Contents?: true
Size: 783 Bytes
Versions: 3
Compression:
Stored size: 783 Bytes
Contents
#!/usr/bin/env ruby require 'rack' # Hat-tip to https://github.com/glasnt for the suggestion module Flapjack module Gateways class JSONAPI < Sinatra::Base module Middleware class ArrayParamFixer < Struct.new(:app) def call(env) if (env["REQUEST_METHOD"] == 'GET') && env["rack.request.query_string"].nil? qs = env["QUERY_STRING"] fixed_qs = qs.to_s.sub(/^filter=/, "filter[]=") .gsub(/&filter=/, "&filter[]=") env["rack.request.query_string"] = qs # avoid Rack re-parsing it env["rack.request.query_hash"] = ::Rack::Utils.parse_nested_query(fixed_qs) end app.call(env) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems