Method: Rack::Handler::Puma.set_host_port_to_config

Defined in:
lib/rack/handler/puma.rb

.set_host_port_to_config(host, port, config) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/rack/handler/puma.rb', line 89

def self.set_host_port_to_config(host, port, config)
  config.clear_binds! if host || port

  if host && (host[0,1] == '.' || host[0,1] == '/')
    config.bind "unix://#{host}"
  elsif host && host =~ /^ssl:\/\//
    uri = URI.parse(host)
    uri.port ||= port || ::Puma::Configuration::DefaultTCPPort
    config.bind uri.to_s
  else

    if host
      port ||= ::Puma::Configuration::DefaultTCPPort
    end

    if port
      host ||= ::Puma::Configuration::DefaultTCPHost
      config.port port, host
    end
  end
end