debian-mirror-gitlab/lib/api/base.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.1 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module API
class Base < Grape::API::Instance # rubocop:disable API/Base
2021-11-18 22:05:49 +05:30
include ::Gitlab::EndpointAttributes
2021-01-29 00:20:46 +05:30
class << self
def feature_category_for_app(app)
feature_category_for_action(path_for_app(app))
end
2021-11-18 22:05:49 +05:30
def urgency_for_app(app)
urgency_for_action(path_for_app(app))
end
2021-01-29 00:20:46 +05:30
def path_for_app(app)
normalize_path(app.namespace, app.options[:path].first)
end
2021-11-18 22:05:49 +05:30
def endpoint_id_for_route(route)
"#{route.request_method} #{route.origin}"
end
2021-01-29 00:20:46 +05:30
def route(methods, paths = ['/'], route_options = {}, &block)
2021-11-18 22:05:49 +05:30
actions = Array(paths).map { |path| normalize_path(namespace, path) }
2021-01-29 00:20:46 +05:30
if category = route_options.delete(:feature_category)
2021-11-18 22:05:49 +05:30
feature_category(category, actions)
end
if target = route_options.delete(:urgency)
urgency(target, actions)
2021-01-29 00:20:46 +05:30
end
super
end
private
def normalize_path(namespace, path)
[namespace.presence, path.to_s.chomp('/').presence].compact.join('/')
end
end
2021-01-03 14:25:43 +05:30
end
end