Sha256: 9043a57d0e7d48454059dab3db1898d55c5796321a79fd28bc6fff477f316842

Contents?: true

Size: 734 Bytes

Versions: 48

Compression:

Stored size: 734 Bytes

Contents

require 'pact/consumer/mock_service/rack_request_helper'

module Pact
  module MockService
    module RequestHandlers
      class BaseRequestHandler

        NOT_FOUND_RESPONSE = [404, {}, []].freeze

        include Pact::Consumer::RackRequestHelper

        def match? env
          raise NotImplementedError
        end

        def call env
          match?(env) ? respond(env) : NOT_FOUND_RESPONSE
        end

        def json_response json = nil, status = 200
          [status, {'Content-Type' => 'application/json'}, json ? [json + "\n"]: []]
        end

        def text_response text = nil, status = 200
          [status, {'Content-Type' => 'text/plain'}, text ? [text + "\n"]: []]
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
pact-mock_service-3.12.3 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.12.2 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.12.1 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.12.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.11.2 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.11.1 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.11.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.10.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
hs-pact-mock_service-3.9.2 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.9.1 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.9.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.8.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.7.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.6.2 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.6.1 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.6.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.5.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.4.0 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.3.1 lib/pact/mock_service/request_handlers/base_request_handler.rb
pact-mock_service-3.3.0 lib/pact/mock_service/request_handlers/base_request_handler.rb