mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
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
|
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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue