summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a83458f3260..b22167a3952 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -21,7 +21,7 @@ class ApplicationController < ActionController::Base
include Impersonation
include Gitlab::Logging::CloudflareHelper
include Gitlab::Utils::StrongMemoize
- include ::Gitlab::WithFeatureCategory
+ include ::Gitlab::EndpointAttributes
include FlocOptOut
before_action :authenticate_user!, except: [:route_not_found]
@@ -70,6 +70,10 @@ class ApplicationController < ActionController::Base
# concerns due to caching private data.
DEFAULT_GITLAB_CACHE_CONTROL = "#{ActionDispatch::Http::Cache::Response::DEFAULT_CACHE_CONTROL}, no-store"
+ def self.endpoint_id_for_action(action_name)
+ "#{self.name}##{action_name}"
+ end
+
rescue_from Encoding::CompatibilityError do |exception|
log_exception(exception)
render "errors/encoding", layout: "errors", status: :internal_server_error
@@ -104,6 +108,12 @@ class ApplicationController < ActionController::Base
head :forbidden, retry_after: Gitlab::Auth::UniqueIpsLimiter.config.unique_ips_limit_time_window
end
+ rescue_from RateLimitedService::RateLimitedError do |e|
+ e.log_request(request, current_user)
+ response.headers.merge!(e.headers)
+ render plain: e.message, status: :too_many_requests
+ end
+
def redirect_back_or_default(default: root_path, options: {})
redirect_back(fallback_location: default, **options)
end
@@ -131,6 +141,14 @@ class ApplicationController < ActionController::Base
end
end
+ def feature_category
+ self.class.feature_category_for_action(action_name).to_s
+ end
+
+ def urgency
+ self.class.urgency_for_action(action_name)
+ end
+
protected
def workhorse_excluded_content_types
@@ -457,7 +475,7 @@ class ApplicationController < ActionController::Base
user: -> { context_user },
project: -> { @project if @project&.persisted? },
namespace: -> { @group if @group&.persisted? },
- caller_id: caller_id,
+ caller_id: self.class.endpoint_id_for_action(action_name),
remote_ip: request.ip,
feature_category: feature_category
)
@@ -543,14 +561,6 @@ class ApplicationController < ActionController::Base
auth_user if strong_memoized?(:auth_user)
end
- def caller_id
- "#{self.class.name}##{action_name}"
- end
-
- def feature_category
- self.class.feature_category_for_action(action_name).to_s
- end
-
def required_signup_info
return unless current_user
return unless current_user.role_required?