invidious-mod-JP/src/invidious/routing.cr
syeopite 7afa027b95
Switch routing logic to use modules (#2298)
* Switch routing logic to use modules
* Add more macros for adding routes of different HTTP methods
2021-08-11 12:36:25 +02:00

12 lines
309 B
Crystal

module Invidious::Routing
{% for http_method in {"get", "post", "delete", "options", "patch", "put", "head"} %}
macro {{http_method.id}}(path, controller, method = :handle)
{{http_method.id}} \{{ path }} do |env|
\{{ controller }}.\{{ method.id }}(env)
end
end
{% end %}
end