Sha256: 5f58b44a7ceb2a1b15634b0d0fded6600f2057f45297febb6fb4965b04b8faea

Contents?: true

Size: 1.21 KB

Versions: 969

Compression:

Stored size: 1.21 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 = 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

969 entries across 969 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.631 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.630 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.629 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.628 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.627 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.626 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.625 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.624 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.623 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.622 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.621 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.620 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.619 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.618 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.617 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.616 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.615 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.614 lib/seahorse/client/plugins/endpoint.rb
aws-sdk-core-2.11.613 lib/seahorse/client/plugins/endpoint.rb