Class: PactBroker::App

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log_error

Constructor Details

#initialize {|configuration| ... } ⇒ App

Returns a new instance of App.

Yields:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pact_broker/app.rb', line 28

def initialize &block
  @app_builder = ::Rack::Builder.new
  @cascade_apps = []
  @make_it_later_api_auth = ::Rack::PactBroker::ConfigurableMakeItLater.new(Rack::PactBroker::NoAuth)
  @make_it_later_ui_auth = ::Rack::PactBroker::ConfigurableMakeItLater.new(Rack::PactBroker::NoAuth)
  @configuration = PactBroker.configuration
  yield configuration
  post_configure
  prepare_database
  load_configuration_from_database
  seed_example_data
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



26
27
28
# File 'lib/pact_broker/app.rb', line 26

def configuration
  @configuration
end

Instance Method Details

#call(env) ⇒ Object



68
69
70
# File 'lib/pact_broker/app.rb', line 68

def call env
  running_app.call env
end

#use(*args, &block) ⇒ Object

Allows middleware to be inserted at the bottom of the shared middlware stack (ie just before the cascade is called for diagnostic, UI and API). To insert middleware at the top of the stack, initialize the middleware with the app, and run it manually. eg run MyMiddleware.new(app)



46
47
48
# File 'lib/pact_broker/app.rb', line 46

def use *args, &block
  @app_builder.use *args, &block
end

#use_api_auth(middleware) ⇒ Object

private API, not sure if this will continue to be supported



51
52
53
# File 'lib/pact_broker/app.rb', line 51

def use_api_auth middleware
  @make_it_later_api_auth.make_it_later(middleware)
end

#use_custom_api(custom_api) ⇒ Object



64
65
66
# File 'lib/pact_broker/app.rb', line 64

def use_custom_api custom_api
  @custom_api = custom_api
end

#use_custom_ui(custom_ui) ⇒ Object



60
61
62
# File 'lib/pact_broker/app.rb', line 60

def use_custom_ui custom_ui
  @custom_ui = custom_ui
end

#use_ui_auth(middleware) ⇒ Object

private API, not sure if this will continue to be supported



56
57
58
# File 'lib/pact_broker/app.rb', line 56

def use_ui_auth middleware
  @make_it_later_ui_auth.make_it_later(middleware)
end