diff --git a/src/invidious.cr b/src/invidious.cr index 4a3b28b12..95e4c2250 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -329,40 +329,7 @@ before_all do |env| env.set "current_page", URI.encode_www_form(current_page) end -{% unless flag?(:api_only) %} - Invidious::Routing.get "/", Invidious::Routes::Misc, :home - Invidious::Routing.get "/privacy", Invidious::Routes::Misc, :privacy - Invidious::Routing.get "/licenses", Invidious::Routes::Misc, :licenses - Invidious::Routing.get "/redirect", Invidious::Routes::Misc, :cross_instance_redirect - - Invidious::Routing.register_channel_routes - Invidious::Routing.register_watch_routes - - Invidious::Routing.register_iv_playlist_routes - Invidious::Routing.register_yt_playlist_routes - - Invidious::Routing.register_search_routes - - # User routes - Invidious::Routing.register_user_routes - - Invidious::Routing.register_feed_routes - - # Support push notifications via PubSubHubbub - Invidious::Routing.get "/feed/webhook/:token", Invidious::Routes::Feeds, :push_notifications_get - Invidious::Routing.post "/feed/webhook/:token", Invidious::Routes::Feeds, :push_notifications_post - - Invidious::Routing.get "/modify_notifications", Invidious::Routes::Notifications, :modify -{% end %} - -Invidious::Routing.register_image_routes - -# API routes (macro) -Invidious::Routing.register_api_v1_routes - -# Video playback (macros) -Invidious::Routing.register_api_manifest_routes -Invidious::Routing.register_video_playback_routes +Invidious::Routing.register_all error 404 do |env| if md = env.request.path.match(/^\/(?([a-zA-Z0-9_-]{11})|(\w+))$/) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index e9657bba6..8084b3e4d 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -11,6 +11,37 @@ module Invidious::Routing {% end %} + def register_all + {% unless flag?(:api_only) %} + get "/", Routes::Misc, :home + get "/privacy", Routes::Misc, :privacy + get "/licenses", Routes::Misc, :licenses + get "/redirect", Routes::Misc, :cross_instance_redirect + + self.register_channel_routes + self.register_watch_routes + + self.register_iv_playlist_routes + self.register_yt_playlist_routes + + self.register_search_routes + + self.register_user_routes + self.register_feed_routes + + # Support push notifications via PubSubHubbub + get "/feed/webhook/:token", Routes::Feeds, :push_notifications_get + post "/feed/webhook/:token", Routes::Feeds, :push_notifications_post + + get "/modify_notifications", Routes::Notifications, :modify + {% end %} + + self.register_image_routes + self.register_api_v1_routes + self.register_api_manifest_routes + self.register_video_playback_routes + end + # ------------------- # Invidious routes # -------------------