Class: PactBroker::App
- Inherits:
-
Object
- Object
- PactBroker::App
- Includes:
- Logging
- Defined in:
- lib/pact_broker/app.rb
Instance Attribute Summary collapse
-
#application_context ⇒ Object
Returns the value of attribute application_context.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(application_context = PactBroker::ApplicationContext.default_application_context) {|configuration| ... } ⇒ App
constructor
A new instance of App.
-
#use(*args, &block) ⇒ Object
Allows middleware to be inserted at the bottom of the shared middleware stack (ie just before the cascade is called for diagnostic, UI and API).
-
#use_api_auth(middleware) ⇒ Object
private API, not sure if this will continue to be supported.
- #use_custom_api(custom_api) ⇒ Object
- #use_custom_ui(custom_ui) ⇒ Object
- #use_to_create_pact_broker_api(&block) ⇒ Object
-
#use_ui_auth(middleware) ⇒ Object
private API, not sure if this will continue to be supported.
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
Constructor Details
#initialize(application_context = PactBroker::ApplicationContext.default_application_context) {|configuration| ... } ⇒ App
Returns a new instance of App.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pact_broker/app.rb', line 40 def initialize(application_context = PactBroker::ApplicationContext.default_application_context) @application_context = application_context @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) # Can only be required after database connection has been made because the decorators rely on the Sequel models @create_pact_broker_api_block = ->() { require "pact_broker/api"; PactBroker.build_api(application_context) } @configuration = PactBroker.configuration yield configuration if block_given? post_configure prepare_database load_configuration_from_database seed_example_data @configuration.freeze end |
Instance Attribute Details
#application_context ⇒ Object
Returns the value of attribute application_context.
38 39 40 |
# File 'lib/pact_broker/app.rb', line 38 def application_context @application_context end |
#configuration ⇒ Object
Returns the value of attribute configuration.
38 39 40 |
# File 'lib/pact_broker/app.rb', line 38 def configuration @configuration end |
Instance Method Details
#call(env) ⇒ Object
89 90 91 |
# File 'lib/pact_broker/app.rb', line 89 def call env running_app.call env end |
#use(*args, &block) ⇒ Object
Allows middleware to be inserted at the bottom of the shared middleware 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)
63 64 65 |
# File 'lib/pact_broker/app.rb', line 63 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
68 69 70 |
# File 'lib/pact_broker/app.rb', line 68 def use_api_auth middleware @make_it_later_api_auth.make_it_later(middleware) end |
#use_custom_api(custom_api) ⇒ Object
81 82 83 |
# File 'lib/pact_broker/app.rb', line 81 def use_custom_api custom_api @custom_api = custom_api end |
#use_custom_ui(custom_ui) ⇒ Object
77 78 79 |
# File 'lib/pact_broker/app.rb', line 77 def use_custom_ui custom_ui @custom_ui = custom_ui end |
#use_to_create_pact_broker_api(&block) ⇒ Object
85 86 87 |
# File 'lib/pact_broker/app.rb', line 85 def use_to_create_pact_broker_api &block @create_pact_broker_api_block = block end |
#use_ui_auth(middleware) ⇒ Object
private API, not sure if this will continue to be supported
73 74 75 |
# File 'lib/pact_broker/app.rb', line 73 def use_ui_auth middleware @make_it_later_ui_auth.make_it_later(middleware) end |