mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Move SSL instance variables into new preview server subclass (#2536)
When the preview server was refactored in e1b0de9
, these SSL-related
variables were left in the original `PreviewServer` -- where the new
`PreviewServer::Webrick` didn't know about them -- causing HTTPS preview
servers to suffer a fatal `NameError` ("undefined local variable or
method 'ssl_certificate'") during `Webrick#setup_webrick`.
This commit changes `Webrick.new` to accept an `ssl_information` hash
containing the necessary instance variables from the `PreviewServer`.
This commit is contained in:
parent
2a0ec8f71a
commit
fda46ad4f7
2 changed files with 11 additions and 5 deletions
|
@ -13,7 +13,7 @@ module Middleman
|
|||
class << self
|
||||
extend Forwardable
|
||||
|
||||
attr_reader :app, :web_server, :ssl_certificate, :ssl_private_key, :environment, :server_information
|
||||
attr_reader :app, :web_server, :ssl_information, :environment, :server_information
|
||||
|
||||
# Start an instance of Middleman::Application
|
||||
# @return [void]
|
||||
|
@ -202,8 +202,10 @@ module Middleman
|
|||
|
||||
@environment = possible_from_cli(:environment, app.config)
|
||||
|
||||
@ssl_certificate = possible_from_cli(:ssl_certificate, app.config)
|
||||
@ssl_private_key = possible_from_cli(:ssl_private_key, app.config)
|
||||
@ssl_information = {
|
||||
ssl_certificate: possible_from_cli(:ssl_certificate, app.config),
|
||||
ssl_private_key: possible_from_cli(:ssl_private_key, app.config)
|
||||
}
|
||||
|
||||
reload_queue = Queue.new
|
||||
|
||||
|
@ -241,6 +243,7 @@ module Middleman
|
|||
@web_server = Webrick.new(
|
||||
::Middleman::Rack.new(app).to_app,
|
||||
server_information,
|
||||
ssl_information,
|
||||
@options[:debug] || false
|
||||
)
|
||||
end
|
||||
|
|
|
@ -7,9 +7,12 @@ require 'webrick/https'
|
|||
module Middleman
|
||||
class PreviewServer
|
||||
class Webrick
|
||||
attr_reader :webrick
|
||||
attr_reader :webrick, :ssl_certificate, :ssl_private_key
|
||||
|
||||
def initialize(rack_app, server_information, ssl_information, is_debug)
|
||||
@ssl_certificate = ssl_information[:ssl_certificate]
|
||||
@ssl_private_key = ssl_information[:ssl_private_key]
|
||||
|
||||
def initialize(rack_app, server_information, is_debug)
|
||||
@webrick = setup_webrick(server_information, is_debug)
|
||||
webrick.mount '/', ::Rack::Handler::WEBrick, rack_app
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue