Added handlers to config
This commit is contained in:
parent
cd0e77aacc
commit
fb1d3c3a85
2 changed files with 14 additions and 5 deletions
|
@ -9,11 +9,10 @@ at_exit do
|
|||
end
|
||||
|
||||
config = Kemal.config
|
||||
handlers = [] of HTTP::Handler
|
||||
handlers << HTTP::LogHandler.new
|
||||
handlers << Kemal::Handler::INSTANCE
|
||||
handlers << HTTP::StaticFileHandler.new("./public")
|
||||
server = HTTP::Server.new(config.port, handlers)
|
||||
config.add_handler HTTP::LogHandler.new
|
||||
config.add_handler Kemal::Handler::INSTANCE
|
||||
config.add_handler HTTP::StaticFileHandler.new("./public")
|
||||
server = HTTP::Server.new(config.port, config.handlers)
|
||||
|
||||
server.ssl = config.ssl
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module Kemal
|
||||
|
||||
class Config
|
||||
INSTANCE = Config.new
|
||||
HANDLERS = [] of HTTP::Handler
|
||||
property ssl
|
||||
property port
|
||||
|
||||
|
@ -11,6 +13,14 @@ module Kemal
|
|||
def scheme
|
||||
ssl ? "https" : "http"
|
||||
end
|
||||
|
||||
def handlers
|
||||
HANDLERS
|
||||
end
|
||||
|
||||
def add_handler(handler : HTTP::Handler)
|
||||
HANDLERS << handler
|
||||
end
|
||||
end
|
||||
|
||||
def self.config
|
||||
|
|
Loading…
Reference in a new issue