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.40.1.rc1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.40.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.39.1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.39.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-1.0.0.dev.1.b305 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.38.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-1.0.0.dev.1.b298 lib/acfs/middleware/msgpack_decoder.rb
acfs-1.0.0.dev.1.b297 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.37.0.1.b295 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.37.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.36.0.1.b293 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.36.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.35.0.1.b291 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.35.0 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.1.1.b289 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.1 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.0.1.b288 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.0.1.b287 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.0.1.b286 lib/acfs/middleware/msgpack_decoder.rb
acfs-0.34.0 lib/acfs/middleware/msgpack_decoder.rb