From 70754659e5e3950c168c74473cc38a9499dc57f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20B=C4=85czek?= Date: Tue, 23 Jan 2024 21:24:08 +0100 Subject: [PATCH] Move `if CONFIG.statistics_enabled` into the handler for the /metrics route --- src/invidious/routes/api/v1/misc.cr | 5 +++++ src/invidious/routing.cr | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index 2a0ce5a7..886aa481 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -29,6 +29,11 @@ module Invidious::Routes::API::V1::Misc end def self.metrics(env) + if !CONFIG.statistics_enabled + env.response.status_code = 204 + return + end + env.response.content_type = "text/plain" return String.build do |str| diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 5ee5ed58..f89a0df9 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -310,13 +310,7 @@ module Invidious::Routing # Misc get "/api/v1/stats", {{namespace}}::Misc, :stats - if CONFIG.statistics_enabled - get "/api/v1/metrics", {{namespace}}::Misc, :metrics - else - get "/api/v1/metrics" do |env| - env.response.status_code = 204 - end - end + get "/api/v1/metrics", {{namespace}}::Misc, :metrics get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes