| Module | Mack::Utils::Server |
| In: |
lib/mack/utils/server.rb
|
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.
# File lib/mack/utils/server.rb, line 12
12: def self.build_app
13: # Mack framework:
14: app = Mack::Runner.new
15:
16: Mack::Utils::RunnersRegistry.registered_items.each do |runner|
17: app = runner.new(app)
18: end
19:
20: # Any urls listed will go straight to the public directly and will not be served up via the app:
21: Mack.search_path(:public, false).reverse.each do |path|
22: app = Mack::Static.new(app, :urls => configatron.mack.static_paths, :root => path)
23: end
24:
25: app = Mack::Static.new(app, :urls => configatron.mack.static_paths, :root => Mack::Paths.public)
26:
27: # app = Mack::Static.new(app)
28: app = Mack::Utils::ContentLengthHandler.new(app)
29: app = Rack::Lint.new(app) if configatron.mack.use_lint
30: app = Rack::ShowStatus.new(app)
31: app = Rack::ShowExceptions.new(app) if configatron.mack.show_exceptions
32: app = Rack::Recursive.new(app)
33:
34: # This will reload any edited classes if the cache_classes config setting is set to true.
35: app = Mack::Reloader.new(app) unless configatron.mack.cache_classes
36: app
37: end