Sha256: dbf1373124658cfad60eca6c6834eca3acd381ac98ad964492ff735d886e004a
Contents?: true
Size: 910 Bytes
Versions: 3
Compression:
Stored size: 910 Bytes
Contents
require 'multi_json' module Esplanade class Response class Raw class Body def initialize(request, raw_response, raw_body) @request = request @raw_response = raw_response @raw_body = raw_body end def to_string @to_string ||= @raw_body.body rescue nil @to_string ||= @raw_body.first rescue nil end def to_hash @hash ||= MultiJson.load(to_string) rescue MultiJson::ParseError raise BodyIsNotJson.new(**message) end private def message { request: { method: @request.raw.method, path: @request.raw.path, raw_path: @request.raw.raw_path }, status: @raw_response.status, body: @raw_response.body.to_string } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
esplanade-1.7.1 | lib/esplanade/response/raw/body.rb |
esplanade-1.7.0 | lib/esplanade/response/raw/body.rb |
esplanade-1.6.0 | lib/esplanade/response/raw/body.rb |