move check for api doc enabledness to before action

Otherwise there is double render happending and it is cleaner to use a
before action than to return when rendirng 404
This commit is contained in:
Ivan Kuchin
2025-12-19 18:23:55 +01:00
parent b793d78a74
commit 6d8b1763df
+8 -3
View File
@@ -29,14 +29,19 @@
#++
class APIDocsController < ApplicationController
before_action :require_login
before_action :require_login,
:check_if_api_docs_enabled
no_authorization_required! :index
helper API::APIDocsHelper
def index
render_404 unless Setting.apiv3_docs_enabled?
render locals: { turbo_opt_out: true }
end
private
def check_if_api_docs_enabled
render_404 unless Setting.apiv3_docs_enabled?
end
end