Class: Apiture::Middleware::SetBodyParameter

Inherits:
SetParameterBase show all
Defined in:
lib/apiture/middleware/set_body_parameter.rb

Instance Method Summary collapse

Methods inherited from SetParameterBase

#call, #initialize

Constructor Details

This class inherits a constructor from Apiture::Middleware::SetParameterBase

Instance Method Details

#apply_parameter_value(env, value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/apiture/middleware/set_body_parameter.rb', line 6

def apply_parameter_value(env, value)
  if value
    env[:body] = if body = env[:body]
      body.merge(value)
    else
      value
    end
    if env[:request_headers]["Content-Type"].nil?
      env[:request_headers]["Content-Type"] = "application/json"
    end
  end
end