Sha256: 61c140cbba4e612c221cbe5de34146e234a2fae7d08aa4510e56ed77f4cc10d4

Contents?: true

Size: 590 Bytes

Versions: 115

Compression:

Stored size: 590 Bytes

Contents

require 'msgpack'
require 'action_dispatch'

module Acfs
  module Middleware

    # Register msgpack mime type
    ::Mime::Type.register 'application/x-msgpack', :msgpack

    # A middleware to decode Message Pack responses.
    #
    class MessagePackDecoder < Base

      CONTENT_TYPES = %w(application/x-msgpack)

      def response(response, nxt)
        response.data = ::MessagePack.unpack(response.body) if message_pack?(response)
        nxt.call response
      end

      def message_pack?(response)
        CONTENT_TYPES.include? response.content_type
      end
    end
  end
end

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
acfs-0.21.0.b185 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.20.0.dev.b184 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.20.0.dev.b183 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.20.0.dev.b182 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.20.0.dev.b181 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.20.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.19.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.18.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.17.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.16.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.15.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.14.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.13.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.12.0 lib/acfs/middleware/msgpack_decoder.rb