class Hub::LocalServer::JsonParamsParser

Public Instance Methods

call(env) click to toggle source
# File features/support/local_server.rb, line 22
def call(env)
  if env['rack.input'] and not input_parsed?(env) and type_match?(env)
    env['rack.request.form_input'] = env['rack.input']
    data = env['rack.input'].read
    env['rack.request.form_hash'] = data.empty?? {} : JSON.parse(data)
  end
  app.call(env)
end
input_parsed?(env) click to toggle source
# File features/support/local_server.rb, line 31
def input_parsed? env
  env['rack.request.form_input'].eql? env['rack.input']
end
type_match?(env) click to toggle source
# File features/support/local_server.rb, line 35
def type_match? env
  type = env['CONTENT_TYPE'] and
    type.split(/\s*[;,]\s*/, 2).first.downcase == 'application/json'
end