Class: Pact::MockService::ControlServer::Index

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

Constant Summary collapse

HTTP_X_PACT_MOCK_SERVICE =
'HTTP_X_PACT_MOCK_SERVICE'
PATH_INFO =
'PATH_INFO'
INDEX_RESPONSE =
[200, {'Content-Type' => 'text/plain'}, ['Control server running']].freeze
NOT_FOUND_RESPONSE =
[404, {}, []].freeze

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/pact/mock_service/control_server/index.rb', line 11

def call env
  if is_index_request_with_mock_service_header? env
    INDEX_RESPONSE
  else
    NOT_FOUND_RESPONSE
  end
end

#is_index_request_with_mock_service_header?(env) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pact/mock_service/control_server/index.rb', line 19

def is_index_request_with_mock_service_header? env
  env[HTTP_X_PACT_MOCK_SERVICE] && env[PATH_INFO].chomp("/").size == 0
end