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.23.1.b198 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.23.1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.23.0.b197 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.2.b196 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.23.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.2.b194 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.2.b193 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.2 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.1.b192 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.0.b191 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.0.b190 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.1.b189 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.1.rc1.b188 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.0.rc1.b187 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.1.rc1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.21.0.rc1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.22.0.rc1.b186 lib/acfs/middleware/msgpack_decoder.rb