Created
December 14, 2012 15:01
-
-
Save dpsk/4286073 to your computer and use it in GitHub Desktop.
Catch Invalid XML error in ActionDispatch::ParamsParser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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