Sha256: 8c7e462472ca52e2efd1565f959e0465e4facab06f5e24f3ae870ce1c8166d69
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
require 'pact_broker/configuration' require 'pact_broker/db' require 'pact_broker/project_root' require 'rack/hal_browser' require 'rack/pact_broker/convert_file_extension_to_accept_header' module PactBroker class App attr_accessor :configuration def initialize &block @configuration = Configuration.default_configuration yield configuration post_configure build_app end def call env @app.call env end private def logger PactBroker.logger end def post_configure PactBroker.logger = configuration.logger PactBroker::DB.connection = configuration.database_connection PactBroker::DB.connection.timezone = :utc if configuration.auto_migrate_db logger.info "Migrating database" PactBroker::DB.run_migrations configuration.database_connection else logger.info "Skipping database migrations" end end def build_app @app = Rack::Builder.new @app.use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts"], :root => PactBroker.project_root.join("public") @app.use Rack::PactBroker::ConvertFileExtensionToAcceptHeader if configuration.use_hal_browser logger.info "Mounting HAL browser" @app.use Rack::HalBrowser::Redirect else logger.info "Not mounting HAL browser" end logger.info "Mounting UI" require 'pact_broker/ui/app' logger.info "Mounting PactBroker::API" require 'pact_broker/api' apps = [PactBroker::UI::App.new, PactBroker::API] @app.map "/" do run Rack::Cascade.new(apps) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pact_broker-1.3.2.rc1 | lib/pact_broker/app.rb |
pact_broker-1.3.1 | lib/pact_broker/app.rb |
pact_broker-1.3.0 | lib/pact_broker/app.rb |