-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch routing logic to use modules (#2298)
* Switch routing logic to use modules * Add more macros for adding routes of different HTTP methods
- Loading branch information
Showing
10 changed files
with
52 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |