Make HTTP::Server uninitialized instead of HTTP::Server?

This commit is contained in:
sdogruyol 2016-09-05 10:38:00 +03:00
parent 8dfe815dc0
commit 64d3271fb2
2 changed files with 5 additions and 5 deletions

View file

@ -11,8 +11,8 @@ module Kemal
config.setup config.setup
config.add_handler Kemal::RouteHandler::INSTANCE config.add_handler Kemal::RouteHandler::INSTANCE
config.server = HTTP::Server.new(config.host_binding.not_nil!, config.port, config.handlers) config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
config.server.not_nil!.tls = config.ssl config.server.tls = config.ssl
Kemal::Sessions.run_reaper! Kemal::Sessions.run_reaper!
@ -26,7 +26,7 @@ module Kemal
unless config.env == "test" unless config.env == "test"
Signal::INT.trap { Signal::INT.trap {
config.logger.write "Kemal is going to take a rest!\n" config.logger.write "Kemal is going to take a rest!\n"
config.server.not_nil!.close config.server.close
exit exit
} }
@ -40,7 +40,7 @@ module Kemal
end end
config.logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n" config.logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
config.server.not_nil!.listen config.server.listen
end end
end end
end end

View file

@ -9,7 +9,6 @@ module Kemal
HANDLERS = [] of HTTP::Handler HANDLERS = [] of HTTP::Handler
ERROR_HANDLERS = {} of Int32 => HTTP::Server::Context -> String ERROR_HANDLERS = {} of Int32 => HTTP::Server::Context -> String
@ssl : OpenSSL::SSL::Context::Server? @ssl : OpenSSL::SSL::Context::Server?
@server : HTTP::Server?
property host_binding, ssl, port, env, public_folder, logging, property host_binding, ssl, port, env, public_folder, logging,
always_rescue, serve_static, server, extra_options always_rescue, serve_static, server, extra_options
@ -24,6 +23,7 @@ module Kemal
@logger = nil @logger = nil
@error_handler = nil @error_handler = nil
@always_rescue = true @always_rescue = true
@server = uninitialized HTTP::Server
end end
def logger def logger