2.6 KiB
stage | group | info |
---|---|---|
none | unassigned | To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers |
Routing
The GitLab backend is written primarily with Rails so it uses Rails routing. Beside Rails best practices, there are few rules unique to the GitLab application. To support subgroups, GitLab project and group routes use the wildcard character to match project and group routes. For example, we might have a path such as:
/gitlab-com/customer-success/north-america/west/customerA
However, paths can be ambiguous. Consider the following example:
/gitlab-com/edit
It's ambiguous whether there is a subgroup named edit
or whether
this is a special endpoint to edit the gitlab-com
group.
To eliminate the ambiguity and to make the backend easier to maintain,
we introduced the /-/
scope. The purpose of it is to separate group or
project paths from the rest of the routes. Also it helps to reduce the
number of reserved names.
Global routes
We have a number of global routes. For example:
/-/health
/-/metrics
Group routes
Every group route must be under the /-/
scope.
Examples:
gitlab-org/-/edit
gitlab-org/-/activity
gitlab-org/-/security/dashboard
gitlab-org/serverless/-/activity
To achieve that, use the scope '-'
method.
Project routes
Every project route must be under the /-/
scope, except cases where a Git
client or other software requires something different.
Examples:
gitlab-org/gitlab/-/activity
gitlab-org/gitlab/-/jobs/123
gitlab-org/gitlab/-/settings/repository
gitlab-org/serverless/runtimes/-/settings/repository
Migrating unscoped routes
Currently, the majority of routes are placed under the /-/
scope. However,
you can help us migrate the rest of them! To migrate routes:
- Modify existing routes by adding
-
scope. - Add redirects for legacy routes by using
Gitlab::Routing.redirect_legacy_paths
. - Create a technical debt issue to remove deprecated routes in later releases.
To get started, see an example merge request.