This commit is contained in:
Fijxu 2026-07-23 15:35:03 -04:00
parent c6dfc0017d
commit 1dceabf4f2
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4

View File

@ -1,20 +1,22 @@
module Invidious::Routes::Companion
extend self
# GET /companion
def self.get_companion(env)
url = self.make_url
self.proxy_companion(env, "GET", url)
def get_companion(env)
url = make_url(env)
proxy_companion(env, "GET", url)
end
# POST /companion
def self.post_companion(env)
url = self.make_url
self.proxy_companion(env, "POST", url)
def post_companion(env)
url = make_url(env)
proxy_companion(env, "POST", url)
end
# OPTIONS /companion
def self.options_companion(env)
url = self.make_url
self.proxy_companion(env, "OPTIONS", url)
def options_companion(env)
url = make_url(env)
proxy_companion(env, "OPTIONS", url)
end
private def make_url(env)
@ -22,9 +24,10 @@ module Invidious::Routes::Companion
if env.request.query
url += "?#{env.request.query}"
end
url
end
private def self.proxy_companion(env, method, url)
private def proxy_companion(env, method, url)
begin
COMPANION_POOL.client do |wrapper|
wrapper.client.exec(method, url, env.request.headers, (env.request.body if method == "POST")) do |resp|