Sha256: 26d1eb9a9e5496d6f308d91ab94c92ebf3a68e3776d4be28405b849aad9528ac

Contents?: true

Size: 712 Bytes

Versions: 20

Compression:

Stored size: 712 Bytes

Contents

# encoding: utf-8

module Hyperdrive
  module Middleware
    class SanitizeParams
      def initialize(app)
        @app = app
      end

      def call(env)
        unless %w(OPTIONS TRACE).include? env['REQUEST_METHOD']
          request = Rack::Request.new(env)
          params = Hyperdrive::Utils.symbolize_keys(request.params)
          if %w(GET HEAD).include? env['REQUEST_METHOD']
            params_to_keep = env['hyperdrive.resource'].filters.keys
          else
            params_to_keep = env['hyperdrive.resource'].params.keys
          end
          env['hyperdrive.params'] = Hyperdrive::Utils.sanitize_keys(params_to_keep, params)
        end
        @app.call(env)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hyperdrive-0.0.25 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.24 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.23 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.22 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.21 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.20 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.19 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.18 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.17 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.16 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.15 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.14 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.13 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.12 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.11 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.10 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.9 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.8 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.7 lib/hyperdrive/middleware/sanitize_params.rb
hyperdrive-0.0.6 lib/hyperdrive/middleware/sanitize_params.rb