Sha256: d03a7a698a8bdc3e1d85b32c0f66b52834889f00fa820353993265d434c876ea
Contents?: true
Size: 777 Bytes
Versions: 51
Compression:
Stored size: 777 Bytes
Contents
require 'faraday' require 'msgpack' module Ably module Rest module Middleware class ParseMessagePack < Faraday::Response::Middleware def on_complete(env) if env.response_headers['Content-Type'] == 'application/x-msgpack' env.body = parse(env.body) unless env.response_headers['Ably-Middleware-Parsed'] == true env.response_headers['Ably-Middleware-Parsed'] = true end end def parse(body) if body.length > 0 MessagePack.unpack(body) else body end rescue MessagePack::MalformedFormatError => e raise Ably::Exceptions::InvalidResponseBody, "Expected MessagePack response: #{e.message}" end end end end end
Version data entries
51 entries across 51 versions & 2 rubygems