Class: Racket::Utils::Application::HandlerStack

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/application/handler_stack.rb

Overview

Class used for building a proper Rack application.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HandlerStack

Returns a new instance of HandlerStack.



54
55
56
57
58
# File 'lib/racket/utils/application/handler_stack.rb', line 54

def initialize(options)
  @stack = Rack::Builder.new
  @options = OpenStruct.new(options)
  build
end

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



26
27
28
# File 'lib/racket/utils/application/handler_stack.rb', line 26

def stack
  @stack
end

Class Method Details

.service(_options = {}) ⇒ Proc

Returns a service proc that can be used by the registry.

Parameters:

  • _options (Hash) (defaults to: {})

    (unused)

Returns:

  • (Proc)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/racket/utils/application/handler_stack.rb', line 32

def self.service(_options = {})
  lambda do |reg|
    settings = reg.application_settings

    options = {
      default_content_type:       settings.default_content_type,
      default_controller_helpers: settings.default_controller_helpers,
      dev_mode:                   settings.mode == :dev,
      logger:                     reg.application_logger,
      middleware:                 settings.middleware,
      plugins:                    settings.plugins,
      router:                     reg.router,
      session_handler:            settings.session_handler,
      static_server:              reg.static_server,
      utils:                      reg.utils,
      warmup_urls:                settings.warmup_urls
    }

    new(options).stack
  end
end