Add support for redirects to go-get middleware
What does this MR do and why?
Contributes to #467850 (closed)
Problem
The new strict version of go-get
validation
!156860 (merged) returns 404
page when the requested project is not found.
That breaks the support for redirected routes.
For example, a project like gitlab.com/namespace/project
can be
accessed via go get
.
go get gitlab.com/namespace/project
Before the restriction we would return a 200 response code, go will follow redirects and process the downloading the package.
The new strict version, will return 404 response code and stop go get
execution.
Solution
Add a verification for redirect routes. When user requests the old path,
go get
response will be 200 and include a link to the new project
path.
How to set up and validate locally
- Enable feature flag
Feature.enable(:not_found_response_for_go_get)
- Create a new project
- Visit URL like
http://gdk.test:3000/<namespace>/<project>?go-get=1
- It should respond with HTTP 200
- Go to Settings -> General -> Advanced -> Change path
- Set a new path for the project
Both URL should return HTTP 200:
-
http://gdk.test:3000/<namespace>/<project>?go-get=1
- HTTP 200 -
http://gdk.test:3000/<namespace>/<new_project_path>?go-get=1
- HTTP 200
Before the fix:
-
http://gdk.test:3000/<namespace>/<project>?go-get=1
- HTTP 404 (cannot access old path) -
http://gdk.test:3000/<namespace>/<new_project_path>?go-get=1
- HTTP 200
Edited by Vasilii Iakliushin