summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-01-17 16:21:35 -0800
committerJeremy Evans <code@jeremyevans.net>2020-01-17 16:31:44 -0800
commit371bd586d188d358875676bc37348db9a0bf7a07 (patch)
tree077a6914c0249f98410a0de0ceecffbec2e717e3
parent8eb03292408f3bf6093ede1858159c616a9daadc (diff)
downloadrack-371bd586d188d358875676bc37348db9a0bf7a07.tar.gz
Update Thin handler to better handle more options
This uses Thin::Controllers::Controller instead of Thin::Server. Thin::Controllers::Controller will do options parsing and then create a Thin::Server instance based on them. Fixes #745
-rw-r--r--lib/rack/handler/thin.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/rack/handler/thin.rb b/lib/rack/handler/thin.rb
index 100dfd11..712ab0a9 100644
--- a/lib/rack/handler/thin.rb
+++ b/lib/rack/handler/thin.rb
@@ -14,14 +14,20 @@ module Rack
environment = ENV['RACK_ENV'] || 'development'
default_host = environment == 'development' ? 'localhost' : '0.0.0.0'
- host = options.delete(:Host) || default_host
- port = options.delete(:Port) || 8080
- args = [host, port, app, options]
- # Thin versions below 0.8.0 do not support additional options
- args.pop if ::Thin::VERSION::MAJOR < 1 && ::Thin::VERSION::MINOR < 8
- server = ::Thin::Server.new(*args)
- yield server if block_given?
- server.start
+ if block_given?
+ host = options.delete(:Host) || default_host
+ port = options.delete(:Port) || 8080
+ args = [host, port, app, options]
+ # Thin versions below 0.8.0 do not support additional options
+ args.pop if ::Thin::VERSION::MAJOR < 1 && ::Thin::VERSION::MINOR < 8
+ server = ::Thin::Server.new(*args)
+ yield server
+ server.start
+ else
+ options[:address] = options[:Host] || default_host
+ options[:port] = options[:Port] || 8080
+ ::Thin::Controllers::Controller.new(options).start
+ end
end
def self.valid_options