I'm integrating a 3rd party API, and at one step they post JSON data into our server.
The content type is application/json
, but the payload is actually gzipped. Due to the content type, rails is throwing an ActionDispatch::ParamsParser::ParseError exception when trying to parse the data.
I plan to write a rack middleware to catch the exception and try and uncompress the payload, but I only want to do it for that particular action, is there a way to execute the middleware only for specific routes?
Update
I'd already thought about pattern matching the path, but ideally I'd like something that is a little more robust in case paths change in the future.
Update
The issue regarding compression is better approached by matt's comment below, and the routing is answered in another question that this is now marked a duplicate of.