Class Index [+]

Quicksearch

Rack::Handler

Handlers connect web servers with Rack.

Rack includes Handlers for Mongrel, WEBrick, FastCGI, CGI, SCGI and LiteSpeed.

Handlers usually are activated by calling MyHandler.run(myapp). A second optional hash can be passed to include server-specific configuration.

Public Class Methods

get(server) click to toggle source

(Not documented)

    # File lib/rack/handler.rb, line 11
11:     def self.get(server)
12:       return unless server
13:       server = server.to_s
14: 
15:       if klass = @handlers[server]
16:         obj = Object
17:         klass.split("::").each { |x| obj = obj.const_get(x) }
18:         obj
19:       else
20:         try_require('rack/handler', server)
21:         const_get(server)
22:       end
23:     end
register(server, klass) click to toggle source

(Not documented)

    # File lib/rack/handler.rb, line 44
44:     def self.register(server, klass)
45:       @handlers ||= {}
46:       @handlers[server] = klass
47:     end
try_require(prefix, const_name) click to toggle source

Transforms server-name constants to their canonical form as filenames, then tries to require them but silences the LoadError if not found

Naming convention:

  Foo # => 'foo'
  FooBar # => 'foo_bar.rb'
  FooBAR # => 'foobar.rb'
  FOObar # => 'foobar.rb'
  FOOBAR # => 'foobar.rb'
  FooBarBaz # => 'foo_bar_baz.rb'
    # File lib/rack/handler.rb, line 36
36:     def self.try_require(prefix, const_name)
37:       file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }.
38:         gsub(/[A-Z]+[^A-Z]/, '_\&').downcase
39: 
40:       require(::File.join(prefix, file))
41:     rescue LoadError
42:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.