mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
v0.6.0
This commit is contained in:
parent
c21567fe17
commit
7ad319c70d
5 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
name: kemal
|
name: kemal
|
||||||
version: 0.5.0
|
version: 0.6.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Serdar Dogruyol <dogruyolserdar@gmail.com>
|
- Serdar Dogruyol <dogruyolserdar@gmail.com>
|
||||||
|
|
|
@ -17,12 +17,18 @@ describe "Config" do
|
||||||
config.env.should eq "development"
|
config.env.should eq "development"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "set environment to production" do
|
it "sets environment to production" do
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
config.env = "production"
|
config.env = "production"
|
||||||
config.env.should eq "production"
|
config.env.should eq "production"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "sets host binding" do
|
||||||
|
config = Kemal.config
|
||||||
|
config.host_binding = "127.0.0.1"
|
||||||
|
config.host_binding.should eq "127.0.0.1"
|
||||||
|
end
|
||||||
|
|
||||||
it "adds a custom handler" do
|
it "adds a custom handler" do
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
config.add_handler CustomTestHandler.new
|
config.add_handler CustomTestHandler.new
|
||||||
|
|
|
@ -18,7 +18,6 @@ describe "Logger" do
|
||||||
logger = Kemal::Logger.new
|
logger = Kemal::Logger.new
|
||||||
logger.handler.should be_a File
|
logger.handler.should be_a File
|
||||||
end
|
end
|
||||||
|
|
||||||
it "writes to a file in production" do
|
it "writes to a file in production" do
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
config.env = "production"
|
config.env = "production"
|
||||||
|
|
|
@ -10,6 +10,9 @@ at_exit do
|
||||||
opts.on("-e ", "--environment ", "environment") do |env|
|
opts.on("-e ", "--environment ", "environment") do |env|
|
||||||
Kemal.config.env = env
|
Kemal.config.env = env
|
||||||
end
|
end
|
||||||
|
opts.on("-b", "--bind", "host binding") do |host_binding|
|
||||||
|
Kemal.config.host_binding = host_binding
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
|
@ -18,9 +21,9 @@ at_exit do
|
||||||
config.add_handler Kemal::StaticFileHandler.new(config.public_folder)
|
config.add_handler Kemal::StaticFileHandler.new(config.public_folder)
|
||||||
config.add_handler Kemal::Handler::INSTANCE
|
config.add_handler Kemal::Handler::INSTANCE
|
||||||
|
|
||||||
server = HTTP::Server.new("0.0.0.0", config.port, config.handlers)
|
server = HTTP::Server.new(config.host_binding.not_nil!.to_slice, config.port, config.handlers)
|
||||||
server.ssl = config.ssl
|
server.ssl = config.ssl
|
||||||
logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://0.0.0.0:#{config.port}\n"
|
logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
|
||||||
|
|
||||||
Signal::INT.trap {
|
Signal::INT.trap {
|
||||||
logger.write "Kemal is going to take a rest!\n"
|
logger.write "Kemal is going to take a rest!\n"
|
||||||
|
|
|
@ -4,9 +4,10 @@ module Kemal
|
||||||
class Config
|
class Config
|
||||||
INSTANCE = Config.new
|
INSTANCE = Config.new
|
||||||
HANDLERS = [] of HTTP::Handler
|
HANDLERS = [] of HTTP::Handler
|
||||||
property ssl, port, env, public_folder
|
property host_binding, ssl, port, env, public_folder
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@host_binding = "0.0.0.0" unless @host_binding
|
||||||
@port = 3000
|
@port = 3000
|
||||||
@env = "development" unless @env
|
@env = "development" unless @env
|
||||||
@public_folder = "./public"
|
@public_folder = "./public"
|
||||||
|
|
Loading…
Reference in a new issue