Sha256: 9eb95577fd362f5989d1f9d4bf28ae0da153ae32e263b6e1b5cf4f470a3c4d7b

Contents?: true

Size: 1.05 KB

Versions: 28

Compression:

Stored size: 1.05 KB

Contents

module Seahorse
  module Client
    module Plugins
      # @seahorse.client.option [String] :endpoint
      #    The HTTP or HTTPS endpoint to send requests to.
      #    For example:
      #
      #        'http://example.com'
      #        'https://example.com'
      #        'http://example.com:123'
      #
      class Endpoint < Plugin

        option(:endpoint)

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

        def after_initialize(client)
          endpoint = URI.parse(client.config.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

28 entries across 28 versions & 1 rubygems

Version Path
aws-sdk-core-2.1.28 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.27 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.26 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.25 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.24 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.23 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.22 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.21 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.20 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.19 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.18 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.17 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.16 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.15 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.14 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.13 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.12 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.11 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.10 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.1.9 lib/seahorse/client/plugins/endpoint.rb