routing: Directly call Kemal's add_route function

This commit is contained in:
Samantaz Fox 2022-08-10 20:50:49 +02:00
parent 848a60aa9b
commit cb8a375c5e
No known key found for this signature in database
GPG Key ID: F42821059186176E
1 changed files with 5 additions and 1 deletions

View File

@ -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