Module: Gitlab::RequestEndpoints

Defined in:
lib/gitlab/request_endpoints.rb

Class Method Summary collapse

Class Method Details

.all_api_endpointsObject



6
7
8
9
10
11
12
13
# File 'lib/gitlab/request_endpoints.rb', line 6

def all_api_endpoints
  # This compile does not do anything if the routes were already built
  # but if they weren't, the routes will be drawn and available for the rest of
  # application.
  API::API.compile!
  API::API.reset_routes!
  API::API.routes.select { |route| route.app.options[:for] < API::Base }
end

.all_controller_actionsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/request_endpoints.rb', line 15

def all_controller_actions
  # This will return tuples of all controller actions defined in the routes
  # Only for controllers inheriting ApplicationController
  # Excluding controllers from gems (OAuth, Sidekiq)
  Rails.application.routes.routes.filter_map do |route|
    route_info = route.required_defaults.presence
    next unless route_info
    next if route_info[:controller].blank? || route_info[:action].blank?

    controller = constantize_controller(route_info[:controller])
    next unless controller&.include?(::Gitlab::EndpointAttributes)
    next if controller == ApplicationController
    next if controller == Devise::UnlocksController

    [controller, route_info[:action]]
  end
end