Skip to content

Instantly share code, notes, and snippets.

@gingerlime
Last active Aug 29, 2015
Embed
What would you like to do?
config.middleware.insert_before ActionDispatch::ParamsParser, ::Rack::Robustness do |g|
g.no_catch_all
# you might need to replace this with JSON::ParserError, depending on your Rails configuration
# or you can catch both...
g.on(MultiJson::ParseError) { |ex| 400 }
g.content_type 'text/plain'
g.body{ |ex| ex.message }
g.ensure(true) do |ex|
env['rack.errors'].write(ex.message)
logger.warn(ex.message)
end
end
@jcuervo
Copy link

jcuervo commented Jan 6, 2015

I changed

logger.warn(ex.message)

to

Rails.logger.warn("RACK ERROR: #{ex.message}")

Thanks for sharing this fix! Initial test would at least get rid of this pesky alihack requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment