Skip to content

Commit

Permalink
Restore thin handler code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 4, 2020
1 parent 59c8a05 commit b201525
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/rack/handler/thin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require "thin"
require "thin/server"
require "thin/logging"
require "thin/backends/tcp_server"

module Rack
module Handler
class Thin
def self.run(app, **options)
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]

server = ::Thin::Server.new(*args)
yield server if block_given?

server.start
end

def self.valid_options
environment = ENV['RACK_ENV'] || 'development'
default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

{
"Host=HOST" => "Hostname to listen on (default: #{default_host})",
"Port=PORT" => "Port to listen on (default: 8080)",
}
end
end
end
end

0 comments on commit b201525

Please sign in to comment.