Disable ssl when `-D without_openssl` is given

This commit is contained in:
maiha 2016-09-16 23:30:36 +09:00
parent 2ff5991c92
commit b2e81e6bc1
3 changed files with 8 additions and 0 deletions

View File

@ -12,7 +12,9 @@ module Kemal
config.add_handler Kemal::RouteHandler::INSTANCE
config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
{% if ! flag?(:without_openssl) %}
config.server.tls = config.ssl
{% end %}
Kemal::Sessions.run_reaper!

View File

@ -39,6 +39,7 @@ module Kemal
end
def configure_ssl
{% if ! flag?(:without_openssl) %}
if @ssl_enabled
puts "SSL Key Not Found"; exit unless @key_file
puts "SSL Certificate Not Found"; exit unless @cert_file
@ -47,6 +48,7 @@ module Kemal
ssl.set_cert_file @cert_file.not_nil!
Kemal.config.ssl = ssl.context
end
{% end %}
end
def read_env

View File

@ -8,7 +8,11 @@ module Kemal
INSTANCE = Config.new
HANDLERS = [] of HTTP::Handler
ERROR_HANDLERS = {} of Int32 => HTTP::Server::Context -> String
{% if flag?(:without_openssl) %}
@ssl : Bool?
{% else %}
@ssl : OpenSSL::SSL::Context::Server?
{% end %}
property host_binding, ssl, port, env, public_folder, logging,
always_rescue, serve_static, server, extra_options