Browse Source
Switch routing logic to use modules (#2298)
Switch routing logic to use modules (#2298)
* Switch routing logic to use modules * Add more macros for adding routes of different HTTP methodspull/2321/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 58 deletions
-
2src/invidious/routes/base_route.cr
-
18src/invidious/routes/channels.cr
-
6src/invidious/routes/embed.cr
-
8src/invidious/routes/login.cr
-
10src/invidious/routes/misc.cr
-
26src/invidious/routes/playlists.cr
-
8src/invidious/routes/preferences.cr
-
8src/invidious/routes/search.cr
-
6src/invidious/routes/watch.cr
-
18src/invidious/routing.cr
@ -1,2 +0,0 @@ |
|||
abstract class Invidious::Routes::BaseRoute |
|||
end |
|||
@ -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 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue