Module: Rack::Handler

Defined in:
lib/rack-handlers.rb

Constant Summary collapse

DEFAULT =
%w[zbatery rainbows unicorn puma thin webrick]

Class Method Summary collapse

Class Method Details

.default(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack-handlers.rb', line 9

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
    pick DEFAULT # We only change this line
  end
end

.pick(server_names) ⇒ Object

Copied from rack 1.5.2 for backward compatibility

Raises:

  • (LoadError)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rack-handlers.rb', line 25

def self.pick(server_names)
  server_names = Array(server_names)
  server_names.each do |server_name|
    begin
      return get(server_name.to_s)
    rescue LoadError, NameError
    end
  end

  raise LoadError, "Couldn't find handler for: #{server_names.join(', ')}."
end