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-3.12.3 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.12.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.12.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.12.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.11.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.11.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.11.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.10.0 lib/pact/consumer/mock_service/set_location.rb
hs-pact-mock_service-3.9.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.9.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.9.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.8.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.7.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.6.2 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.6.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.6.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.5.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.4.0 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.3.1 lib/pact/consumer/mock_service/set_location.rb
pact-mock_service-3.3.0 lib/pact/consumer/mock_service/set_location.rb