fix getting params with post and put request with json body

Sébastien BEAU committed Jun 13, 2018
commit 496006ce0661ae95e11fd91782079bd0577e8a38
Showing 1 changed file with 7 additions and 1 deletions
locomotive/steam/middlewares/thread_safe.rb b/lib/locomotive/steam/middlewares/thread_safe.rb +7 -1
@@ @@ -66,7 +66,13 @@ module Locomotive::Steam::Middlewares
end
def params
- @params ||= self.request.params.with_indifferent_access
+ req = self.request
+ if req.content_type == 'application/json' && (req.post? || req.put?)
+ req.body.rewind
+ @params ||= JSON.parse(req.body.read).with_indifferent_access
+ else
+ @params ||= req.params.with_indifferent_access
+ end
end
def live_editing?