Module: Mack::Utils::Server

Defined in:
lib/utils/server.rb

Class Method Summary collapse

Class Method Details

.build_appObject

This method wraps all the necessary components of the Rack system around Mack::Runner. This can be used build your own server around the Mack framework.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/utils/server.rb', line 7

def self.build_app
  # Mack framework:
  app = Mack::Runner.new
  # Any urls listed will go straight to the public directly and will not be served up via the app:
  app = Rack::Static.new(app, :urls => ["/css", "/images", "/files", "/images", "/stylesheets", "/javascripts", "/media"], :root => "public")
  app = Rack::Lint.new(app) if app_config.mack.use_lint 
  app = Rack::ShowStatus.new(app) 
  app = Rack::ShowExceptions.new(app) if app_config.mack.show_exceptions
  app = Rack::Recursive.new(app)
  # This will reload any edited classes if the cache_classes config setting is set to true.
  app = Rack::Reloader.new(app, 1) unless app_config.mack.cache_classes
  # TODO: Not sure about this logger, investigate better ones.
  # TODO: Depends on MACK_DEFAULT_LOGGER already being configured.
  # This makes it a drag run this 'standalone' in another Ruby program.
  # app = Rack::CommonLogger.new(app, MACK_DEFAULT_LOGGER)
  app
end