Move HTTPS to server_information
This commit is contained in:
parent
ec99a7b28f
commit
a61b2e3b87
|
@ -15,10 +15,6 @@ module Middleman
|
||||||
|
|
||||||
attr_reader :app, :ssl_certificate, :ssl_private_key, :environment, :server_information
|
attr_reader :app, :ssl_certificate, :ssl_private_key, :environment, :server_information
|
||||||
|
|
||||||
def https?
|
|
||||||
@https == true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start an instance of Middleman::Application
|
# Start an instance of Middleman::Application
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def start(opts={})
|
def start(opts={})
|
||||||
|
@ -28,6 +24,7 @@ module Middleman
|
||||||
|
|
||||||
@options = opts
|
@options = opts
|
||||||
@server_information = ServerInformation.new
|
@server_information = ServerInformation.new
|
||||||
|
@server_information.https = (@options[:https] == true)
|
||||||
|
|
||||||
# New app evaluates the middleman configuration. Since this can be
|
# New app evaluates the middleman configuration. Since this can be
|
||||||
# invalid as well, we need to evaluate the configuration BEFORE
|
# invalid as well, we need to evaluate the configuration BEFORE
|
||||||
|
@ -44,9 +41,9 @@ module Middleman
|
||||||
|
|
||||||
app.logger.debug %(== Server information is provided by #{server_information.handler})
|
app.logger.debug %(== Server information is provided by #{server_information.handler})
|
||||||
app.logger.debug %(== The Middleman is running in "#{environment}" environment)
|
app.logger.debug %(== The Middleman is running in "#{environment}" environment)
|
||||||
app.logger.debug format('== The Middleman preview server is bound to %s', ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: https?).to_bind_addresses.join(', '))
|
app.logger.debug format('== The Middleman preview server is bound to %s', ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: server_information.https?).to_bind_addresses.join(', '))
|
||||||
app.logger.info format('== View your site at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: https?).to_urls.join(', '))
|
app.logger.info format('== View your site at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_urls.join(', '))
|
||||||
app.logger.info format('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: https?).to_config_urls.join(', '))
|
app.logger.info format('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_config_urls.join(', '))
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
return if @initialized
|
return if @initialized
|
||||||
|
@ -170,7 +167,6 @@ module Middleman
|
||||||
|
|
||||||
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless app.config[:port] == configured_port
|
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless app.config[:port] == configured_port
|
||||||
|
|
||||||
@https = app.config[:https]
|
|
||||||
@environment = app.config[:environment]
|
@environment = app.config[:environment]
|
||||||
|
|
||||||
@ssl_certificate = app.config[:ssl_certificate]
|
@ssl_certificate = app.config[:ssl_certificate]
|
||||||
|
@ -216,7 +212,7 @@ module Middleman
|
||||||
DoNotReverseLookup: true
|
DoNotReverseLookup: true
|
||||||
}
|
}
|
||||||
|
|
||||||
if https?
|
if server_information.https?
|
||||||
http_opts[:SSLEnable] = true
|
http_opts[:SSLEnable] = true
|
||||||
|
|
||||||
if ssl_certificate || ssl_private_key
|
if ssl_certificate || ssl_private_key
|
||||||
|
|
|
@ -20,6 +20,8 @@ module Middleman
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
|
attr_writer :https
|
||||||
|
|
||||||
def initialize(opts={})
|
def initialize(opts={})
|
||||||
@resolver = opts.fetch(:resolver, DnsResolver.new)
|
@resolver = opts.fetch(:resolver, DnsResolver.new)
|
||||||
@validator = opts.fetch(:validator, ServerInformationValidator.new)
|
@validator = opts.fetch(:validator, ServerInformationValidator.new)
|
||||||
|
@ -64,10 +66,12 @@ module Middleman
|
||||||
@bind_address = config[:bind_address]
|
@bind_address = config[:bind_address]
|
||||||
@port = config[:port]
|
@port = config[:port]
|
||||||
@server_name = config[:server_name]
|
@server_name = config[:server_name]
|
||||||
|
@https = config[:https]
|
||||||
|
|
||||||
config[:bind_address] = bind_address
|
config[:bind_address] = bind_address
|
||||||
config[:port] = port
|
config[:port] = port
|
||||||
config[:server_name] = server_name
|
config[:server_name] = server_name
|
||||||
|
config[:https] = https?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make information of internal server class avaible to make debugging
|
# Make information of internal server class avaible to make debugging
|
||||||
|
@ -139,6 +143,11 @@ module Middleman
|
||||||
def listeners
|
def listeners
|
||||||
information.listeners
|
information.listeners
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Is https enabled?
|
||||||
|
def https?
|
||||||
|
@https == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue