Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2023-06-08 09:54:32 +0300
committerJaime Martinez <jmartinez@gitlab.com>2023-06-08 09:54:32 +0300
commite64dbc90aec2a9e75e3e8b8141cb25ac0a89554f (patch)
treeab4c8aea756d110ec1e676ee6088327809803b2e /internal/serving/disk/reader.go
parent5a6388a4479dcfbd522a55b525127f9096e79cdc (diff)
parent3cbfc605d0ede7e0a79d912fac01d610089f7eef (diff)
Merge branch '1056-use-pages-root-directory-from-api' into 'master'
Use pages root directory from API Closes #1056 See merge request https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/859 Merged-by: Jaime Martinez <jmartinez@gitlab.com> Approved-by: Jaime Martinez <jmartinez@gitlab.com> Reviewed-by: Kassio Borges <kborges@gitlab.com> Reviewed-by: Jaime Martinez <jmartinez@gitlab.com> Reviewed-by: Janis Altherr <jaltherr@gitlab.com> Co-authored-by: janis <jaltherr@gitlab.com>
Diffstat (limited to 'internal/serving/disk/reader.go')
-rw-r--r--internal/serving/disk/reader.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go
index f250a0d6..7a1af61b 100644
--- a/internal/serving/disk/reader.go
+++ b/internal/serving/disk/reader.go
@@ -18,6 +18,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/logging"
"gitlab.com/gitlab-org/gitlab-pages/internal/redirects"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/projectroot"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/symlink"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
vfsServing "gitlab.com/gitlab-org/gitlab-pages/internal/vfs/serving"
@@ -284,11 +285,18 @@ func (reader *Reader) serveCustomFile(ctx context.Context, w http.ResponseWriter
return nil
}
-// root tries to resolve the vfs.Root and handles errors for it.
+// root tries to resolve the vfs.Root, wrap it in a projectroot.Root and handles
+// errors for it.
// It returns whether we served the response or not.
func (reader *Reader) root(h serving.Handler) (vfs.Root, bool) {
- root, err := reader.vfs.Root(h.Request.Context(), h.LookupPath.Path, h.LookupPath.SHA256)
+ vfsRoot, err := reader.vfs.Root(h.Request.Context(), h.LookupPath.Path,
+ h.LookupPath.SHA256)
+
if err == nil {
+ // The project root directory changes based on the response obtained
+ // from the API. It currently depends on feature.ConfigurableRoot
+ // being enabled.
+ root := projectroot.New(h.LookupPath.RootDirectory, vfsRoot)
return root, false
}