Class: Pact::MockService::ControlServer::Delegator

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/mock_service/control_server/delegator.rb

Constant Summary collapse

HTTP_X_PACT_CONSUMER =
'HTTP_X_PACT_CONSUMER'.freeze
HTTP_X_PACT_PROVIDER =
'HTTP_X_PACT_PROVIDER'.freeze
PACT_MOCK_SERVICE_HEADER =
{'HTTP_X_PACT_MOCK_SERVICE' => 'true'}.freeze
NOT_FOUND_RESPONSE =
[404, {}, []].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, consumer_name, provider_name) ⇒ Delegator

Returns a new instance of Delegator.



17
18
19
20
21
# File 'lib/pact/mock_service/control_server/delegator.rb', line 17

def initialize app, consumer_name, provider_name
  @app = app
  @consumer_name = consumer_name
  @provider_name = provider_name
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
# File 'lib/pact/mock_service/control_server/delegator.rb', line 23

def call env
  return NOT_FOUND_RESPONSE unless consumer_and_provider_headers_match?(env)
  delegate env
end

#shutdownObject



28
29
30
# File 'lib/pact/mock_service/control_server/delegator.rb', line 28

def shutdown
  @app.shutdown
end