Class: Rack::RespondToMalformedFormats

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/respond_to_malformed_formats.rb

Constant Summary collapse

VERSION =
"0.0.4"

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ RespondToMalformedFormats

Returns a new instance of RespondToMalformedFormats.



10
11
12
# File 'lib/rack/respond_to_malformed_formats.rb', line 10

def initialize(app, options = {})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/respond_to_malformed_formats.rb', line 14

def call(env)
  if malformed_response = respond_to_malformed_parameters(env)
    input = env["rack.input"]
    input.rewind
    logger = env["rack.logger"]
    logger.error "Error occurred while parsing request.\nInput:\n\n#{input.read}" if logger
    malformed_response
  else
    @app.call(env)
  end
end