Renamed all occurrences to Kemal

This commit is contained in:
Sdogruyol 2015-10-23 21:33:26 +03:00
parent 289ad42d4e
commit 5ca84fea4c
13 changed files with 38 additions and 38 deletions

View file

@ -1,7 +0,0 @@
def get(path, &block : Frank::Context -> _)
Frank::Handler::INSTANCE.add_route("GET", path, &block)
end
def post(path, &block : Frank::Context -> _)
Frank::Handler::INSTANCE.add_route("POST", path, &block)
end

View file

@ -1,17 +1,17 @@
require "option_parser"
require "./frank/*"
require "./Kemal/*"
at_exit do
OptionParser.parse! do |opts|
opts.on("-p ", "--port ", "port") do |opt_port|
Frank.config.port = opt_port.to_i
Kemal.config.port = opt_port.to_i
end
end
config = Frank.config
config = Kemal.config
handlers = [] of HTTP::Handler
handlers << HTTP::LogHandler.new
handlers << Frank::Handler::INSTANCE
handlers << Kemal::Handler::INSTANCE
handlers << HTTP::StaticFileHandler.new("./public")
server = HTTP::Server.new(config.port, handlers)

View file

@ -1,4 +1,4 @@
module Frank
module Kemal
class Config
INSTANCE = Config.new
property ssl

View file

@ -1,4 +1,4 @@
class Frank::Context
class Kemal::Context
getter request
def initialize(@request)

7
src/kemal/dsl.cr Normal file
View file

@ -0,0 +1,7 @@
def get(path, &block : Kemal::Context -> _)
Kemal::Handler::INSTANCE.add_route("GET", path, &block)
end
def post(path, &block : Kemal::Context -> _)
Kemal::Handler::INSTANCE.add_route("POST", path, &block)
end

View file

@ -1,7 +1,7 @@
require "http/server"
require "uri"
class Frank::Handler < HTTP::Handler
class Kemal::Handler < HTTP::Handler
INSTANCE = new
def initialize
@ -13,7 +13,7 @@ class Frank::Handler < HTTP::Handler
response || call_next(request)
end
def add_route(method, path, &handler : Frank::Context -> _)
def add_route(method, path, &handler : Kemal::Context -> _)
@routes << Route.new(method, path, &handler)
end
@ -30,8 +30,8 @@ class Frank::Handler < HTTP::Handler
params[key] ||= value
end
frank_request = Request.new(request, params)
context = Context.new(frank_request)
kemal_request = Request.new(request, params)
context = Context.new(kemal_request)
begin
body = route.handler.call(context).to_s
content_type = context.response?.try(&.content_type) || "text/plain"

View file

@ -1,4 +1,4 @@
class Frank::Request
class Kemal::Request
getter params
def initialize(@request, @params)

View file

@ -1,3 +1,3 @@
class Frank::Response
class Kemal::Response
property content_type
end

View file

@ -1,7 +1,7 @@
class Frank::Route
class Kemal::Route
getter handler
def initialize(@method, path, &@handler : Frank::Context -> _)
def initialize(@method, path, &@handler : Kemal::Context -> _)
@components = path.split "/"
end