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>2020-10-13 07:43:23 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-10-14 07:17:12 +0300
commit2533637ca527243c743458a573f80cc6dddd4644 (patch)
treebe07cbae967a75e679708588824583089a0ddc8e
parent72f6878d0de009f57720726a741af2610bc61d6e (diff)
Cleanup a bit
-rw-r--r--internal/domain/domain.go26
-rw-r--r--internal/serving/disk/reader.go8
2 files changed, 4 insertions, 30 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index fe34d4d2..076dea0c 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -10,7 +10,6 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
- "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/local"
)
// Domain is a domain that gitlab-pages can serve.
@@ -49,34 +48,13 @@ func (d *Domain) isSameProject(reqPath string) bool {
func (d *Domain) resolve(r *http.Request) *serving.Request {
if d.isSameProject(r.URL.Path) {
- // // && strings.
- // // Contains(r.URL.
- // // Path,
- // // d.servingRequest.LookupPath.Path) {
- // fmt.Printf("d.resolve d: %q - count: %d\n - r.URL."+
- // "Path: %q - servingReq.Path: %q - servingReq."+
- // "SubPath: %q\n",
- // d.Name,
- // count[d.Name],
- // r.URL.Path,
- // d.servingRequest.LookupPath.Path,
- // d.servingRequest.LookupPath.SubPath,
- // )
return d.servingRequest
}
- request, _ := d.Resolver.Resolve(r)
-
- // TODO improve code around default serving, when `disk` serving gets removed
- // https://gitlab.com/gitlab-org/gitlab-pages/issues/353
- if request == nil {
- request = &serving.Request{Serving: local.Instance()}
- }
-
// store serving.Request to avoid calling d.Resolver.Resolve multiple times
- d.servingRequest = request
+ d.servingRequest, _ = d.Resolver.Resolve(r)
- return request
+ return d.servingRequest
}
// GetLookupPath returns a project details based on the request. It returns nil
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go
index 28ca1114..34f2c5fc 100644
--- a/internal/serving/disk/reader.go
+++ b/internal/serving/disk/reader.go
@@ -61,12 +61,8 @@ func (reader *Reader) tryFile(w http.ResponseWriter, r *http.Request, lookupPath
return err
}
- fullPath, err := reader.resolvePath(ctx, root, lookupPath.SubPath)
-
- // request := h.Request
- host := r.Host
urlPath := r.URL.Path
-
+ fullPath, err := reader.resolvePath(ctx, root, lookupPath.SubPath)
if locationError, _ := err.(*locationDirectoryError); locationError != nil {
if endsWithSlash(urlPath) {
fullPath, err = reader.resolvePath(ctx, root, lookupPath.SubPath,
@@ -76,7 +72,7 @@ func (reader *Reader) tryFile(w http.ResponseWriter, r *http.Request, lookupPath
// issue about this: https://gitlab.com/gitlab-org/gitlab-pages/issues/273
// Concat Host with URL.Path
- redirectPath := "//" + host + "/"
+ redirectPath := "//" + r.Host + "/"
redirectPath += strings.TrimPrefix(urlPath, "/")
// Ensure that there's always "/" at end