Sha256: a0b169b84d915249d2a7b53100b0c29d64f33faa0eccb0455753120bbc495a09

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

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

9 entries across 9 versions & 1 rubygems

Version Path
rack-2.1.4.4 lib/rack/handler/thin.rb
rack-2.1.4.3 lib/rack/handler/thin.rb
rack-2.1.4.2 lib/rack/handler/thin.rb
rack-2.1.4.1 lib/rack/handler/thin.rb
rack-2.1.4 lib/rack/handler/thin.rb
rack-2.1.3 lib/rack/handler/thin.rb
rack-2.1.2 lib/rack/handler/thin.rb
rack-2.1.1 lib/rack/handler/thin.rb
rack-2.1.0 lib/rack/handler/thin.rb