Sha256: 58aa095857e7459d07cdeab2896a230fee2c16963fd4ef9301715b35ad903803

Contents?: true

Size: 989 Bytes

Versions: 5

Compression:

Stored size: 989 Bytes

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]

        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

    register :thin, ::Rack::Handler::Thin
  end
end

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
thin-1.8.2 lib/rack/handler/thin.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/thin-1.8.1/lib/rack/handler/thin.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/thin-1.8.1/lib/rack/handler/thin.rb
thin-1.8.1 lib/rack/handler/thin.rb
thin-1.8.0 lib/rack/handler/thin.rb