Sha256: 45deec2ff82df8eff7609d44b2f07299a3a0f7982ab68714a34e136d77713d82

Contents?: true

Size: 657 Bytes

Versions: 80

Compression:

Stored size: 657 Bytes

Contents

module Pact
  module Consumer
    class SetLocation

      LOCATION = 'X-Pact-Mock-Service-Location'.freeze
      HTTP_X_PACT_MOCK_SERVICE = 'HTTP_X_PACT_MOCK_SERVICE'

      def initialize app, base_url
        @app = app
        @location_header = {LOCATION => base_url}.freeze
      end

      def call env
        response = @app.call(env)
        env[HTTP_X_PACT_MOCK_SERVICE] ? add_location_header_to_response(response) : response
      end

      def add_location_header_to_response response
        [response.first, response[1].merge(@location_header), response.last]
      end

      def shutdown
        @app.shutdown
      end

    end
  end
end

Version data entries

80 entries across 80 versions & 2 rubygems

Version Path
pact-mock_service-2.6.3 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.6.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.6.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.5.4 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.5.3 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.5.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.4.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.3.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.2.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.1.1.pre.alpha.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.1.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.0.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-2.0.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-1.2.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-1.1.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-1.0.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-0.12.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-0.12.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-0.11.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-0.10.2 lib/pact/consumer/mock_service/set_location.rb