Sha256: 708e6d9b8c56a6b13a21b61d7b704ca4962ed02f5b9176fb88f4a01543cb6954

Contents?: true

Size: 592 Bytes

Versions: 2

Compression:

Stored size: 592 Bytes

Contents

module Calabash
  module HTTP
    class ForwardingClient
      HEADER_FORWARD = 'X-FORWARD-PORT'
      ROUTES = [:get, :post, :put, :delete]

      def initialize(client, forward_to_port)
        @client = client
        @forward_to_port = forward_to_port
      end

      ROUTES.each do |route|
        define_method(route) do |request, options = {}|
          new_options = options.clone
          new_options[:header] ||= {}
          new_options[:header][HEADER_FORWARD] = @forward_to_port.to_s

          @client.send(route, request, new_options)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
calabash-2.0.0.pre11 lib/calabash/http/forwarding_client.rb
calabash-2.0.0.pre10 lib/calabash/http/forwarding_client.rb