class Rack::App::Payload::Parser
Constants
- DEFAULT_PARSER
Public Class Methods
new(content_type__parsers = {})
click to toggle source
# File lib/rack/app/payload/parser.rb, line 8 def initialize(content_type__parsers = {}) raise unless content_type__parsers.is_a?(Hash) @content_type__parsers = content_type__parsers end
Public Instance Methods
parse_env(env)
click to toggle source
# File lib/rack/app/payload/parser.rb, line 17 def parse_env(env) request = Rack::Request.new(env) parse_io(request.content_type, request.body) end
parse_io(content_type, io)
click to toggle source
# File lib/rack/app/payload/parser.rb, line 13 def parse_io(content_type, io) parser_for(content_type.to_s).call(io) end
parse_string(content_type, str)
click to toggle source
# File lib/rack/app/payload/parser.rb, line 22 def parse_string(content_type, str) parse_io(content_type, StringIO.new(str)) end
Protected Instance Methods
parser_for(content_type)
click to toggle source
# File lib/rack/app/payload/parser.rb, line 28 def parser_for(content_type) @content_type__parsers[content_type] || DEFAULT_PARSER end