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