Module: Rack::Handler

### Home Classes Methods

### In Files

- lib/rack/handler/webrick.rb
- lib/rack/handler/swiftiplied_mongrel.rb
- lib/rack/handler/fastcgi.rb
- lib/rack/handler/mongrel.rb
- lib/rack/handler/scgi.rb
- lib/rack/handler/thin.rb
- lib/rack/handler/cgi.rb
- lib/rack/handler/evented_mongrel.rb
- lib/rack/handler/lsws.rb
- lib/rack/handler.rb

### Namespace

- CLASS Rack::Handler::CGI
- CLASS Rack::Handler::EventedMongrel
- CLASS Rack::Handler::FastCGI
- CLASS Rack::Handler::LSWS
- CLASS Rack::Handler::Mongrel
- CLASS Rack::Handler::SCGI
- CLASS Rack::Handler::SwiftipliedMongrel
- CLASS Rack::Handler::Thin
- CLASS Rack::Handler::WEBrick

### Methods

- ::default
- ::get
- ::register
- ::try_require

### Files

- KNOWN-ISSUES
- README
- SPEC

### Class/Module Index

Quicksearch

- Rack
- Rack::Auth
- Rack::Auth::AbstractHandler
- Rack::Auth::AbstractRequest
- Rack::Auth::Basic
- Rack::Auth::Basic::Request
- Rack::Auth::Digest
- Rack::Auth::Digest::MD5
- Rack::Auth::Digest::Nonce
- Rack::Auth::Digest::Params
- Rack::Auth::Digest::Request
- Rack::Builder
- Rack::Cascade
- Rack::Chunked
- Rack::CommonLogger
- Rack::ConditionalGet
- Rack::Config
- Rack::ContentLength
- Rack::ContentType
- Rack::Deflater
- Rack::Deflater::DeflateStream
- Rack::Deflater::GzipStream
- Rack::Directory
- Rack::ETag
- Rack::File
- Rack::ForwardRequest
- Rack::Handler
- Rack::Handler::CGI
- Rack::Handler::EventedMongrel
- Rack::Handler::FastCGI
- Rack::Handler::LSWS
- Rack::Handler::Mongrel
- Rack::Handler::SCGI
- Rack::Handler::SwiftipliedMongrel
- Rack::Handler::Thin
- Rack::Handler::WEBrick
- Rack::Head
- Rack::Lint
- Rack::Lobster
- Rack::Lock
- Rack::Logger
- Rack::MethodOverride
- Rack::Mime
- Rack::MockRequest
- Rack::MockRequest::FatalWarner
- Rack::MockRequest::FatalWarning
- Rack::MockResponse
- Rack::NullLogger
- Rack::Recursive
- Rack::Reloader
- Rack::Reloader::Stat
- Rack::Request
- Rack::Response
- Rack::Response::Helpers
- Rack::RewindableInput
- Rack::RewindableInput::Tempfile
- Rack::Runtime
- Rack::Sendfile
- Rack::Server
- Rack::Server::Options
- Rack::Session
- Rack::Session::Abstract
- Rack::Session::Abstract::ID
- Rack::Session::Cookie
- Rack::Session::Memcache
- Rack::Session::Pool
- Rack::ShowExceptions
- Rack::ShowStatus
- Rack::Static
- Rack::URLMap
- Rack::Utils
- Rack::Utils::Context
- Rack::Utils::HeaderHash
- Rack::Utils::Multipart
- Rack::Utils::Multipart::UploadedFile
- FCGI
- FCGI::Stream

No matching classes.

# 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

default(options = {}) click to toggle source

    # File lib/rack/handler.rb, line 25
    def self.default(options = {})
      # Guess.
      if ENV.include?("PHP_FCGI_CHILDREN")
        # We already speak FastCGI
        options.delete :File
        options.delete :Port

        Rack::Handler::FastCGI
      elsif ENV.include?("REQUEST_METHOD")
        Rack::Handler::CGI
      else
        begin
          Rack::Handler::Mongrel
        rescue LoadError => e
          Rack::Handler::WEBrick
        end
      end
    end

get(server) click to toggle source

    # File lib/rack/handler.rb, line 11
    def self.get(server)
      return unless server
      server = server.to_s

      if klass = @handlers[server]
        obj = Object
        klass.split("::").each { |x| obj = obj.const_get(x) }
        obj
      else
        try_require('rack/handler', server)
        const_get(server)
      end
    end

register(server, klass) click to toggle source

    # File lib/rack/handler.rb, line 63
    def self.register(server, klass)
      @handlers ||= {}
      @handlers[server] = klass
    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 55
    def self.try_require(prefix, const_name)
      file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }.
        gsub(/[A-Z]+[^A-Z]/, '_\&').downcase

      require(::File.join(prefix, file))
    rescue LoadError
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.