Class: Authsignal::Middleware::JsonRequest

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/authsignal/middleware/json_request.rb

Instance Method Summary collapse

Instance Method Details

#on_request(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/authsignal/middleware/json_request.rb', line 6

def on_request(env)
  return if env.body.nil?

  parsed_body = JSON.parse(env.body)
  if parsed_body.is_a?(Hash)
    env.body = camelcase_keys(parsed_body).to_json
  end
rescue JSON::ParserError
  # noop
end