Skip to content

Instantly share code, notes, and snippets.

@gingerlime
Last active August 29, 2015 14:05
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gingerlime/18f1a64a4c2a252ca766 to your computer and use it in GitHub Desktop.
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