Sha256: 89fe0078a7ce2bb60d57bfe30083fe797514670872cda2c21b8a78288c1f6e03

Contents?: true

Size: 1.41 KB

Versions: 165

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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 or custom 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

165 entries across 165 versions & 1 rubygems

Version Path
aws-sdk-core-3.197.2 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.197.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.197.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.194.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.194.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.193.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.192.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.192.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.6 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.5 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.4 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.3 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.2 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.191.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.190.3 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.190.2 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.190.1 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.190.0 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-3.189.0 lib/seahorse/client/plugins/endpoint.rb