Sha256: 012441876d65ec666576fc99e6b9b0c06e60d412bfe74334edc48f4d307b033e

Contents?: true

Size: 1.37 KB

Versions: 159

Compression:

Stored size: 1.37 KB

Contents

module Seahorse
  module Client
    module Plugins
      class Endpoint < Plugin

        option(:endpoint,
          doc_type: 'String, URI::HTTPS, URI::HTTP',
          docstring: <<-DOCS)
Normally you should not configure the `:endpoint` option
directly. This is normally constructed from the `:region`
option. Configuring `:endpoint` is normally reserved for
connecting to test endpoints. The endpoint should be a URI
formatted like:

    'http://example.com'
    'https://example.com'
    'http://example.com:123'

          DOCS

        def add_handlers(handlers, config)
          handlers.add(Handler, priority: 90)
        end

        def after_initialize(client)
          endpoint = client.config.endpoint
          if endpoint.nil?
            msg = "missing required option `:endpoint'"
            raise ArgumentError, msg
          end

          endpoint = URI.parse(endpoint.to_s)
          if URI::HTTPS === endpoint or URI::HTTP === endpoint
            client.config.endpoint = endpoint
          else
            msg = 'expected :endpoint to be a HTTP or HTTPS endpoint'
            raise ArgumentError, msg
          end
        end

        class Handler < Client::Handler

          def call(context)
            context.http_request.endpoint = URI.parse(context.config.endpoint.to_s)
            @handler.call(context)
          end

        end
      end
    end
  end
end

Version data entries

159 entries across 159 versions & 1 rubygems

Version Path
aws-sdk-core-3.98.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.97.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.97.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.96.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.96.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.95.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.94.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.94.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.93.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.92.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.91.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.91.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.90.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.90.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.89.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.89.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.88.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.87.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.86.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.85.1 lib/seahorse/client/plugins/endpoint.rb