diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2022-08-10 20:50:49 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2022-08-10 20:50:49 +0200 |
| commit | cb8a375c5e7ae79cad8daa9430b65c68f50e2885 (patch) | |
| tree | 1a88050b562ab13d9ab1835a3d1c5133f7e6b451 | |
| parent | 848a60aa9bfca457ae6e1a470d6fcf3ef03a1f38 (diff) | |
| download | invidious-cb8a375c5e7ae79cad8daa9430b65c68f50e2885.tar.gz invidious-cb8a375c5e7ae79cad8daa9430b65c68f50e2885.tar.bz2 invidious-cb8a375c5e7ae79cad8daa9430b65c68f50e2885.zip | |
routing: Directly call Kemal's add_route function
| -rw-r--r-- | src/invidious/routing.cr | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 8084b3e4..b1cef086 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -4,7 +4,11 @@ module Invidious::Routing {% for http_method in {"get", "post", "delete", "options", "patch", "put"} %} 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) end end |
