diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2023-06-08 09:54:32 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2023-06-08 09:54:32 +0300 |
commit | e64dbc90aec2a9e75e3e8b8141cb25ac0a89554f (patch) | |
tree | ab4c8aea756d110ec1e676ee6088327809803b2e /internal/serving/disk/reader.go | |
parent | 5a6388a4479dcfbd522a55b525127f9096e79cdc (diff) | |
parent | 3cbfc605d0ede7e0a79d912fac01d610089f7eef (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.go | 12 |
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 } |