forked from midou/invidious
Switch routing logic to use modules (#2298)
* Switch routing logic to use modules * Add more macros for adding routes of different HTTP methods
This commit is contained in:
1 parent
637a5cc14f
commit
7afa027b95
10 files changed
+52
-58
No files matched your search
@@ -1,15 +1,11 @@
|
||||
module Invidious::Routing
|
||||
macro get(path, controller, method = :handle)
|
||||
get {{ path }} do |env|
|
||||
controller_instance = {{ controller }}.new
|
||||
controller_instance.{{ 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_instance = {{ controller }}.new
|
||||
controller_instance.{{ 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
|
||||
Reference in new issue
Block a user