Sha256: d1a6500d0532a48c1fb0236f1b86f786a19c7d500562454966f8b5aa3d3e6cab

Contents?: true

Size: 1.26 KB

Versions: 74

Compression:

Stored size: 1.26 KB

Contents

require 'base64'

require 'ably/version'

require 'ably/rest/middleware/encoder'
require 'ably/rest/middleware/external_exceptions'
require 'ably/rest/middleware/fail_if_unsupported_mime_type'
require 'ably/rest/middleware/logger'
require 'ably/rest/middleware/parse_json'
require 'ably/rest/middleware/parse_message_pack'

module Ably::Modules
  # HttpHelpers provides common private methods to classes to simplify HTTP interactions with Ably
  module HttpHelpers
    protected
    def encode64(text)
      Base64.encode64(text).gsub("\n", '')
    end

    def user_agent
      "Ably Ruby client #{Ably::VERSION} (https://www.ably.io)"
    end

    def setup_outgoing_middleware(builder)
      # Convert request params to "www-form-urlencoded"
      builder.use Ably::Rest::Middleware::Encoder
    end

    def setup_incoming_middleware(builder, logger, options = {})
      builder.use Ably::Rest::Middleware::Logger, logger

      # Parse JSON / MsgPack response bodies. ParseJson must be first (default) parsing middleware
      if options[:fail_if_unsupported_mime_type] == true
        builder.use Ably::Rest::Middleware::FailIfUnsupportedMimeType
      end

      builder.use Ably::Rest::Middleware::ParseJson
      builder.use Ably::Rest::Middleware::ParseMessagePack
    end
  end
end

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
ably-rest-1.1.5 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.5 lib/ably/modules/http_helpers.rb
ably-rest-1.1.4 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.4 lib/ably/modules/http_helpers.rb
ably-rest-1.1.4.rc lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.4.rc lib/ably/modules/http_helpers.rb
ably-rest-1.1.3 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.3 lib/ably/modules/http_helpers.rb
ably-rest-1.1.2 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.2 lib/ably/modules/http_helpers.rb
ably-rest-1.1.2.rc1 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.1 lib/ably/modules/http_helpers.rb
ably-rest-1.1.0 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.1.0 lib/ably/modules/http_helpers.rb
ably-1.0.7 lib/ably/modules/http_helpers.rb
ably-rest-1.0.6 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.0.6 lib/ably/modules/http_helpers.rb
ably-rest-1.0.5 lib/submodules/ably-ruby/lib/ably/modules/http_helpers.rb
ably-1.0.5 lib/ably/modules/http_helpers.rb
ably-1.0.4 lib/ably/modules/http_helpers.rb