diff --git a/src/kemal/handler.cr b/src/kemal/handler.cr index 2102bf4..069c64d 100644 --- a/src/kemal/handler.cr +++ b/src/kemal/handler.cr @@ -9,18 +9,18 @@ module Kemal @@exclude_routes_tree = Radix::Tree(String).new macro only(paths, method = "GET") - class_name = {{@type.name}} - ({{paths}}).each do |path| - @@only_routes_tree.add "#{class_name}/#{{{method}}.downcase}#{path}", "/#{{{method}}.downcase}#{path}" + class_name = {{@type.name}} + ({{paths}}).each do |path| + @@only_routes_tree.add "#{class_name}/#{{{method}}.downcase}#{path}", "/#{{{method}}.downcase}#{path}" + end end - end macro exclude(paths, method = "GET") - class_name = {{@type.name}} - ({{paths}}).each do |path| - @@exclude_routes_tree.add "#{class_name}/#{{{method}}.downcase}#{path}", "/#{{{method}}.downcase}#{path}" + class_name = {{@type.name}} + ({{paths}}).each do |path| + @@exclude_routes_tree.add "#{class_name}/#{{{method}}.downcase}#{path}", "/#{{{method}}.downcase}#{path}" + end end - end def call(env : HTTP::Server::Context) call_next(env) diff --git a/src/kemal/param_parser.cr b/src/kemal/param_parser.cr index b8a6c35..d2893cb 100644 --- a/src/kemal/param_parser.cr +++ b/src/kemal/param_parser.cr @@ -29,15 +29,15 @@ module Kemal end {% for method in %w(url query body json) %} - def {{method.id}} - # check memoization - return @{{method.id}} if @{{method.id}}_parsed + def {{method.id}} + # check memoization + return @{{method.id}} if @{{method.id}}_parsed - parse_{{method.id}} - # memoize - @{{method.id}}_parsed = true - @{{method.id}} - end + parse_{{method.id}} + # memoize + @{{method.id}}_parsed = true + @{{method.id}} + end {% end %} private def parse_body