Sha256: 659bd6711cf1d883b601a57d906383bf4ec05639ae216632a17f54222fe86471

Contents?: true

Size: 1.07 KB

Versions: 62

Compression:

Stored size: 1.07 KB

Contents

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

62 entries across 46 versions & 15 rubygems

Version Path
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/handler/thin.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb
rack-2.2.3 lib/rack/handler/thin.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/handler/thin.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/handler/thin.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/handler/thin.rb