Bountiful changes

- Use haltf in more locations
 - Fix wrong URL params
 - Rename API modules
 - Remove API routing file and move everything to general iv routing
   file
This commit is contained in:
syeopite
2021-08-23 16:28:30 -07:00
parent 39b34eece8
commit 66b45a8fe2
10 changed files with 122 additions and 119 deletions

View File

@@ -1,4 +1,4 @@
module Invidious::Routes::APIv1::Channels
module Invidious::Routes::API::V1::Channels
def self.home(env)
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@@ -241,7 +241,7 @@ module Invidious::Routes::APIv1::Channels
end
end
def self.channel_search(env)
def self.search(env)
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
env.response.content_type = "application/json"
@@ -263,4 +263,15 @@ module Invidious::Routes::APIv1::Channels
end
end
end
# 301 redirect from /api/v1/channels/comments/:ucid
# and /api/v1/channels/:ucid/comments to new /api/v1/channels/:ucid/community and
# corresponding equivalent URL structure of the other one.
def self.channel_comments_redirect(env)
env.response.content_type = "application/json"
ucid = env.params.url["ucid"]
env.response.headers["Location"] = "/api/v1/channels/#{ucid}/community?#{env.params.query}"
haltf env, status_code: 301
end
end