Update handler

This commit is contained in:
sdogruyol 2016-04-12 17:35:29 +03:00
parent c47c9488fe
commit b4bc818490
3 changed files with 3 additions and 3 deletions

View file

@ -1,7 +1,7 @@
HTTP_METHODS = %w(get post put patch delete options)
{% for method in HTTP_METHODS %}
def {{method.id}}(path, &block : HTTP::Server::Context -> String)
def {{method.id}}(path, &block : HTTP::Server::Context -> _)
Kemal::RouteHandler::INSTANCE.add_route({{method}}.upcase, path, &block)
end
{% end %}

View file

@ -6,7 +6,7 @@ class Kemal::Route
@handler : HTTP::Server::Context -> String
@method : String
def initialize(@method, @path : String, &handler )
def initialize(@method, @path : String, &handler : HTTP::Server::Context -> _)
@handler = ->(context : HTTP::Server::Context){ handler.call(context).to_s }
end
end

View file

@ -19,7 +19,7 @@ class Kemal::RouteHandler < HTTP::Handler
# Adds a given route to routing tree. As an exception each `GET` route additionaly defines
# a corresponding `HEAD` route.
def add_route(method, path, &handler : HTTP::Server::Context -> String)
def add_route(method, path, &handler : HTTP::Server::Context -> _)
add_to_radix_tree method, path, Route.new(method, path, &handler)
add_to_radix_tree("HEAD", path, Route.new("HEAD", path, &handler)) if method == "GET"
end