Skip to content

Commit 7075465

Browse files
author
Mateusz Bączek
committed
Move if CONFIG.statistics_enabled into the handler for the /metrics route
1 parent 8d4c16c commit 7075465

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/invidious/routes/api/v1/misc.cr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ module Invidious::Routes::API::V1::Misc
2929
end
3030

3131
def self.metrics(env)
32+
if !CONFIG.statistics_enabled
33+
env.response.status_code = 204
34+
return
35+
end
36+
3237
env.response.content_type = "text/plain"
3338

3439
return String.build do |str|

src/invidious/routing.cr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,7 @@ module Invidious::Routing
310310

311311
# Misc
312312
get "/api/v1/stats", {{namespace}}::Misc, :stats
313-
if CONFIG.statistics_enabled
314-
get "/api/v1/metrics", {{namespace}}::Misc, :metrics
315-
else
316-
get "/api/v1/metrics" do |env|
317-
env.response.status_code = 204
318-
end
319-
end
313+
get "/api/v1/metrics", {{namespace}}::Misc, :metrics
320314
get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist
321315
get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist
322316
get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes

0 commit comments

Comments
 (0)