lib/rack/handler.rb in rack-2.0.9.4 vs lib/rack/handler.rb in rack-2.1.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Rack
# *Handlers* connect web servers with Rack.
#
# Rack includes Handlers for Thin, WEBrick, FastCGI, CGI, SCGI
# and LiteSpeed.
@@ -15,11 +17,11 @@
unless @handlers.include? server
load_error = try_require('rack/handler', server)
end
if klass = @handlers[server]
- klass.split("::").inject(Object) { |o, x| o.const_get(x) }
+ const_get(klass)
else
const_get(server, false)
end
rescue NameError => name_error
@@ -41,19 +43,22 @@
end
raise LoadError, "Couldn't find handler for: #{server_names.join(', ')}."
end
+ SERVER_NAMES = %w(puma thin falcon webrick).freeze
+ private_constant :SERVER_NAMES
+
def self.default
# Guess.
if ENV.include?("PHP_FCGI_CHILDREN")
Rack::Handler::FastCGI
elsif ENV.include?(REQUEST_METHOD)
Rack::Handler::CGI
elsif ENV.include?("RACK_HANDLER")
self.get(ENV["RACK_HANDLER"])
else
- pick ['puma', 'thin', 'webrick']
+ pick SERVER_NAMES
end
end
# Transforms server-name constants to their canonical form as filenames,
# then tries to require them but silences the LoadError if not found