Sha256: 5140b0f786dccb653a8be439577bf454bdfd61f661cf2aa09a2058d88199b6d6

Contents?: true

Size: 381 Bytes

Versions: 5

Compression:

Stored size: 381 Bytes

Contents

module BodyParser
  module_function

  JSON_TYPE = "application/json"

  # Parses the body
  def parse(params, body, content_type)
    case content_type
    when JSON_TYPE 
      params.merge(json_parser.parse(body.string))
    else
      params
    end
  end

  def json_parser=(parser_klass)
    @json_parser = parser_klass
  end

  def json_parser
    @json_parser
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wd_sinatra-0.2.1 templates/lib/body_parser.rb
wd_sinatra-0.2.0 templates/lib/body_parser.rb
wd_sinatra-0.1.0 templates/lib/body_parser.rb
wd_sinatra-0.0.2 templates/lib/body_parser.rb
wd_sinatra-0.0.1 templates/lib/body_parser.rb