Add more macros for adding routes of HTTP methods

This commit is contained in:
syeopite 2021-08-03 10:58:02 -07:00
parent cce239a1cf
commit e8ab18f0e8
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82

View File

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