Ensure before_all handler is called first

This commit is contained in:
syeopite 2024-11-10 00:47:39 -08:00
parent 5bf4e20c5a
commit 49c40b3bc3
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
2 changed files with 11 additions and 3 deletions

View File

@ -207,9 +207,9 @@ end
# Routing
before_all do |env|
Invidious::Routes::BeforeAll.handle(env)
end
# Custom handlers actually has a higher priority than the handler defined via
# before_all
add_handler TrueBeforeAllHandler.new
Invidious::Routing.register_all

View File

@ -60,6 +60,14 @@ class Kemal::ExceptionHandler
end
end
class TrueBeforeAllHandler < Kemal::Handler
def call(env)
return call_next(env) unless env.route_found?
Invidious::Routes::BeforeAll.handle(env)
call_next env
end
end
class FilteredCompressHandler < Kemal::Handler
exclude ["/videoplayback", "/videoplayback/*", "/vi/*", "/sb/*", "/ggpht/*", "/api/v1/auth/notifications"]
exclude ["/api/v1/auth/notifications", "/data_control"], "POST"