Added handlers to config

This commit is contained in:
Sdogruyol 2015-11-12 22:48:22 +02:00
parent cd0e77aacc
commit fb1d3c3a85
2 changed files with 14 additions and 5 deletions

View file

@ -9,11 +9,10 @@ at_exit do
end end
config = Kemal.config config = Kemal.config
handlers = [] of HTTP::Handler config.add_handler HTTP::LogHandler.new
handlers << HTTP::LogHandler.new config.add_handler Kemal::Handler::INSTANCE
handlers << Kemal::Handler::INSTANCE config.add_handler HTTP::StaticFileHandler.new("./public")
handlers << HTTP::StaticFileHandler.new("./public") server = HTTP::Server.new(config.port, config.handlers)
server = HTTP::Server.new(config.port, handlers)
server.ssl = config.ssl server.ssl = config.ssl

View file

@ -1,6 +1,8 @@
module Kemal module Kemal
class Config class Config
INSTANCE = Config.new INSTANCE = Config.new
HANDLERS = [] of HTTP::Handler
property ssl property ssl
property port property port
@ -11,6 +13,14 @@ module Kemal
def scheme def scheme
ssl ? "https" : "http" ssl ? "https" : "http"
end end
def handlers
HANDLERS
end
def add_handler(handler : HTTP::Handler)
HANDLERS << handler
end
end end
def self.config def self.config