Sha256: a5365034b86777eac251705a1fda216e124a06fbab9b2933ed27eeddfe1de754

Contents?: true

Size: 1.09 KB

Versions: 55

Compression:

Stored size: 1.09 KB

Contents

require "thin"
require "thin/server"
require "thin/logging"
require "thin/backends/tcp_server"
require "rack/content_length"
require "rack/chunked"

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]
        # 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
      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

Version data entries

55 entries across 53 versions & 14 rubygems

Version Path
rack-2.0.3 lib/rack/handler/thin.rb
rack-2.0.2 lib/rack/handler/thin.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
abaci-0.3.0 vendor/bundle/gems/rack-2.0.1/lib/rack/handler/thin.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/rack-2.0.1/lib/rack/handler/thin.rb
rack-2.0.1 lib/rack/handler/thin.rb
rack-2.0.0.rc1 lib/rack/handler/thin.rb
rack-2.0.0.alpha lib/rack/handler/thin.rb