diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-04-13 12:32:58 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-04-13 13:09:09 -0700 |
commit | f015875071b44e63b626490055858d6c9c179a7a (patch) | |
tree | 10cb1a84912ceadfdeb95bacdebcad907cf5dd7b | |
parent | b0c2656921aec622de72cfe114cb7da0bf408993 (diff) | |
download | rack-f015875071b44e63b626490055858d6c9c179a7a.tar.gz |
Remove the autoload of Rack::Handler::WEBrick
There isn't a reason the constant needs to be autoloaded. If puma or falcon is not installed, the try_require will still load the webrick handler file, so register the the handler in the handler file, similar to how puma and falcon handle it. This makes webrick support less special.
-rw-r--r-- | lib/rack/handler.rb | 6 | ||||
-rw-r--r-- | lib/rack/handler/webrick.rb | 3 | ||||
-rw-r--r-- | test/spec_webrick.rb | 1 |
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/rack/handler.rb b/lib/rack/handler.rb index 3d99b85d..e5843d3c 100644 --- a/lib/rack/handler.rb +++ b/lib/rack/handler.rb @@ -9,6 +9,8 @@ module Rack # A second optional hash can be passed to include server-specific # configuration. module Handler + @handlers = {} + def self.get(server) return unless server server = server.to_s @@ -79,11 +81,7 @@ module Rack end def self.register(server, klass) - @handlers ||= {} @handlers[server.to_s] = klass.to_s end - - autoload :WEBrick, "rack/handler/webrick" - register 'webrick', 'Rack::Handler::WEBrick' end end diff --git a/lib/rack/handler/webrick.rb b/lib/rack/handler/webrick.rb index 9044ab78..a82dd585 100644 --- a/lib/rack/handler/webrick.rb +++ b/lib/rack/handler/webrick.rb @@ -4,6 +4,7 @@ require 'webrick' require 'stringio' require_relative '../constants' +require_relative '../handler' require_relative '../version' # This monkey patch allows for applications to perform their own chunking @@ -124,5 +125,7 @@ module Rack end end end + + register 'webrick', WEBrick end end diff --git a/test/spec_webrick.rb b/test/spec_webrick.rb index 948f69f8..322672ac 100644 --- a/test/spec_webrick.rb +++ b/test/spec_webrick.rb @@ -3,6 +3,7 @@ require_relative 'helper' require 'thread' require 'webrick' +require 'rack/handler/webrick' require_relative 'test_request' separate_testing do |