Class: Hyperdrive::Middleware::SanitizeParams
- Inherits:
-
Object
- Object
- Hyperdrive::Middleware::SanitizeParams
- Defined in:
- lib/hyperdrive/middleware/sanitize_params.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ SanitizeParams
constructor
A new instance of SanitizeParams.
Constructor Details
#initialize(app) ⇒ SanitizeParams
Returns a new instance of SanitizeParams.
6 7 8 |
# File 'lib/hyperdrive/middleware/sanitize_params.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hyperdrive/middleware/sanitize_params.rb', line 10 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 |