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.
# File lib/rack/handler.rb, line 25 25: def self.default(options = {}) 26: # Guess. 27: if ENV.include?("PHP_FCGI_CHILDREN") 28: # We already speak FastCGI 29: options.delete :File 30: options.delete :Port 31: 32: Rack::Handler::FastCGI 33: elsif ENV.include?("REQUEST_METHOD") 34: Rack::Handler::CGI 35: else 36: begin 37: Rack::Handler::Mongrel 38: rescue LoadError => e 39: Rack::Handler::WEBrick 40: end 41: end 42: end
# 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
# File lib/rack/handler.rb, line 63 63: def self.register(server, klass) 64: @handlers ||= {} 65: @handlers[server] = klass 66: end
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 55 55: def self.try_require(prefix, const_name) 56: file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }. 57: gsub(/[A-Z]+[^A-Z]/, '_\&').downcase 58: 59: require(::File.join(prefix, file)) 60: rescue LoadError 61: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.