Class: JettyRails::Handler::PublicDirectoryHandler

Inherits:
DelegateOnErrorsHandler show all
Defined in:
lib/jetty_rails/handler/public_directory_handler.rb

Instance Method Summary collapse

Methods inherited from DelegateOnErrorsHandler

#handle

Constructor Details

#initialize(config) ⇒ PublicDirectoryHandler

Returns a new instance of PublicDirectoryHandler.



6
7
8
9
10
11
12
13
# File 'lib/jetty_rails/handler/public_directory_handler.rb', line 6

def initialize(config)
  super()
  @config = config
  @resources = Jetty::Handler::ResourceHandler.new
  @resources.resource_base = @config[:base] + '/public'
  context_capable = add_context_capability_to @resources
  self.handler = context_capable
end

Instance Method Details

#add_context_capability_to(handler) ⇒ Object



15
16
17
18
19
20
# File 'lib/jetty_rails/handler/public_directory_handler.rb', line 15

def add_context_capability_to(handler)
  return handler if @config[:context_path].root?
  context_handler = Jetty::Handler::ContextHandler.new(@config[:context_path])
  context_handler.handler = handler
  context_handler
end