mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-16 09:58:50 +00:00
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,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