Sha256: 04ef19e02456a61eb1dbd4866732a4438671aed3acaad320c7406bd1cae3d88c
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
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 ||= MultiJson.load(to_string) rescue MultiJson::ParseError raise BodyIsNotJson.new(**message) end def reduced_version @reduced_version ||= if to_string && to_string.size >= 1000 "#{to_string[0..499]}...#{to_string[500..-1]}" else to_string end end private def message { method: @raw_request.method, path: @raw_request.path, content_type: @raw_request.content_type, body: reduced_version } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
esplanade-1.5.0 | lib/esplanade/request/raw/body.rb |