Class: PactBroker::Diagnostic::App

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/diagnostic/app.rb

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



9
10
11
# File 'lib/pact_broker/diagnostic/app.rb', line 9

def initialize
  @app = build_diagnostic_app
end

Instance Method Details

#build_diagnostic_appObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pact_broker/diagnostic/app.rb', line 21

def build_diagnostic_app
  app = Webmachine::Application.new do |app|
    app.routes do
      add ['diagnostic','status','heartbeat'], Diagnostic::Resources::Heartbeat, {resource_name: 'diagnostic_heartbeat'}
      add ['diagnostic','status','dependencies'], Diagnostic::Resources::Dependencies, {resource_name: 'diagnostic_dependencies'}
    end
  end

  app.configure do |config|
    config.adapter = :RackMapped
  end

  app.adapter
end

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/pact_broker/diagnostic/app.rb', line 13

def call env
  if env['PATH_INFO'].start_with? "/diagnostic/"
    @app.call(env)
  else
    [404, {}, []]
  end
end