Skip to content

Instantly share code, notes, and snippets.

@dpsk
Created December 14, 2012 15:01
Show Gist options
  • Save dpsk/4286073 to your computer and use it in GitHub Desktop.
Save dpsk/4286073 to your computer and use it in GitHub Desktop.
Catch Invalid XML error in ActionDispatch::ParamsParser
if defined?(ActionDispatch)
class MyParamsParser < ActionDispatch::ParamsParser
def call(env)
super
rescue REXML::ParseException
[400, {"Content-Type" => "application/xml"}, ["Invalid Request"]]
end
end
end
config.middleware.swap ActionDispatch::ParamsParser, MyParamsParser if defined?(MyParamsParser)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment