mirror of
https://github.com/iv-org/invidious.git
synced 2024-08-30 18:23:25 +00:00
routing: Directly call Kemal's add_route function
This commit is contained in:
parent
848a60aa9b
commit
cb8a375c5e
@ -4,7 +4,11 @@ module Invidious::Routing
|
|||||||
{% for http_method in {"get", "post", "delete", "options", "patch", "put"} %}
|
{% for http_method in {"get", "post", "delete", "options", "patch", "put"} %}
|
||||||
|
|
||||||
macro {{http_method.id}}(path, controller, method = :handle)
|
macro {{http_method.id}}(path, controller, method = :handle)
|
||||||
{{http_method.id}} \{{ path }} do |env|
|
unless !Kemal::Utils.path_starts_with_slash?(\{{path}})
|
||||||
|
raise Kemal::Exceptions::InvalidPathStartException.new({{http_method}}, \{{path}})
|
||||||
|
end
|
||||||
|
|
||||||
|
Kemal::RouteHandler::INSTANCE.add_route({{http_method.upcase}}, \{{path}}) do |env|
|
||||||
\{{ controller }}.\{{ method.id }}(env)
|
\{{ controller }}.\{{ method.id }}(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user