Fixed macros indentation (#409)

This commit is contained in:
Sijawusz Pur Rahnama 2017-10-06 13:55:37 +02:00 committed by Serdar Dogruyol
parent 210e2c0801
commit 1d8908e673
2 changed files with 16 additions and 16 deletions

View file

@ -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)

View file

@ -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