2018-11-06 04:45:35 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-07 13:47:28 +00:00
|
|
|
module Gitlab
|
|
|
|
module EtagCaching
|
2021-02-24 12:10:54 +00:00
|
|
|
module Router
|
|
|
|
Route = Struct.new(:regexp, :name, :feature_category, :router) do
|
|
|
|
delegate :match, to: :regexp
|
|
|
|
delegate :cache_key, to: :router
|
|
|
|
end
|
2017-06-01 08:31:33 +00:00
|
|
|
|
2021-02-24 12:10:54 +00:00
|
|
|
module Helpers
|
|
|
|
def build_route(attrs)
|
|
|
|
EtagCaching::Router::Route.new(*attrs, self)
|
|
|
|
end
|
|
|
|
end
|
2017-04-07 13:47:28 +00:00
|
|
|
|
2021-02-24 12:10:54 +00:00
|
|
|
# Performing RESTful routing match before GraphQL would be more expensive
|
|
|
|
# for the GraphQL requests because we need to traverse all of the RESTful
|
|
|
|
# route definitions before falling back to GraphQL.
|
|
|
|
def self.match(request)
|
|
|
|
Router::Graphql.match(request) || Router::Restful.match(request)
|
2017-04-07 13:47:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|