Adding port to Kemal#run (#208)

Adding port to Kemal#run
This commit is contained in:
Aurelien Louis Dit Picard 2016-09-21 00:27:35 +01:00 committed by Serdar Dogruyol
parent d41ad90826
commit 39cfe14811
1 changed files with 4 additions and 1 deletions

View File

@ -5,11 +5,14 @@ require "./kemal/middleware/*"
module Kemal
# The command to run a `Kemal` application.
def self.run
# The port can be given to `#run` but is optionnal.
# If not given Kemal will use the default config port (`Kemal::Config#port`)
def self.run(port = nil)
Kemal::CLI.new
config = Kemal.config
config.setup
config.add_handler Kemal::RouteHandler::INSTANCE
config.port = port if port
config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
{% if ! flag?(:without_openssl) %}