Add more documentation

This commit is contained in:
Sdogruyol 2016-04-18 21:40:48 +03:00
parent a8ecbde222
commit 18efc4601f
6 changed files with 10 additions and 2 deletions

View File

@ -2,6 +2,8 @@ require "./kemal/*"
require "./kemal/middleware/*"
module Kemal
# The command to run a `Kemal` application.
def self.run
Kemal::CLI.new
config = Kemal.config
@ -11,6 +13,7 @@ module Kemal
config.server = HTTP::Server.new(config.host_binding.not_nil!, config.port, config.handlers)
config.server.not_nil!.ssl = config.ssl
# Test environment doesn't need to have signal trap, built-in images, and logging.
unless config.env == "test"
Signal::INT.trap {
config.logger.write "Kemal is going to take a rest!\n"

View File

@ -1,5 +1,6 @@
require "http"
# All loggers must inherit from `Kemal::BaseLogHandler`.
class Kemal::BaseLogHandler < HTTP::Handler
def initialize(@env : String)
end

View File

@ -1,6 +1,7 @@
require "option_parser"
module Kemal
# Handles all the initialization from the command line.
class CLI
@config : Kemal::Config
@key_file : String

View File

@ -5,7 +5,6 @@ require "kilt"
# get '/' do
# render 'hello.ecr'
# end
macro render(filename, layout)
content = render {{filename}}
render {{layout}}
@ -21,6 +20,7 @@ macro return_with(env, status_code = 200, response = "")
next
end
# Adds given HTTP::Handler+ to handlers.
def add_handler(handler)
Kemal.config.add_handler handler
end
@ -31,6 +31,8 @@ def basic_auth(username, password)
add_handler auth_handler
end
# Sets public folder from which the static assets will be served.
# By default this is `/public` not `src/public`.
def public_folder(path)
Kemal.config.public_folder = path
end

View File

@ -1,2 +1,3 @@
# This is here to represend the logger corresponding to Null Object Pattern.
class Kemal::NullLogHandler < Kemal::BaseLogHandler
end

View File

@ -1,4 +1,4 @@
# Kemal::WebSocketHandler is used for each define WebSocket route.
# Kemal::WebSocketHandler is used for building a WebSocket route.
# For each WebSocket route a new handler is created and registered to global handlers.
class Kemal::WebSocketHandler < HTTP::WebSocketHandler
def initialize(@path : String, &@proc : HTTP::WebSocket, HTTP::Server::Context -> Void)