Sha256: cb54bd04de02be7b38bbd655886a9ca674f9b539c22b10f33dc0ec357e88d24b
Contents?: true
Size: 843 Bytes
Versions: 3
Compression:
Stored size: 843 Bytes
Contents
require 'multi_json' module Esplanade class Request class Raw class Body def initialize(raw_request, env) @raw_request = raw_request @env = env end def to_string return @string if @string @string = @env['rack.input'].read @env['rack.input'].rewind @string end def to_hash @hash ||= if to_string.nil? {} else MultiJson.load(to_string) end rescue MultiJson::ParseError raise BodyIsNotJson, message end private def message { method: @raw_request.method, path: @raw_request.path, body: to_string } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
esplanade-1.2.1 | lib/esplanade/request/raw/body.rb |
esplanade-1.2.0 | lib/esplanade/request/raw/body.rb |
esplanade-1.1.2 | lib/esplanade/request/raw/body.rb |