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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 15:13:32 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 15:13:32 +0300
commitc7e283a96f8fe340304f399efc75ec2b62134dca (patch)
tree23977020c5ae0c774cae017a08597f4bd7bd7188 /internal
parentb859280bce9e347987e0878ae28aee8033954158 (diff)
Ensure that we not do return nil serving.Request
Diffstat (limited to 'internal')
-rw-r--r--internal/domain/domain.go8
-rw-r--r--internal/serving/request.go4
-rw-r--r--internal/source/gitlab/gitlab.go2
3 files changed, 9 insertions, 5 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index af238668..9ac668a5 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -8,6 +8,7 @@ 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"
)
// Domain is a domain that gitlab-pages can serve.
@@ -37,9 +38,12 @@ func (d *Domain) isUnconfigured() bool {
}
func (d *Domain) resolve(r *http.Request) *serving.Request {
- // Current implementation does not return errors in any case
request, _ := d.Resolver.Resolve(r)
+ if request == nil {
+ return &serving.Request{Serving: disk.New()}
+ }
+
return request
}
@@ -52,7 +56,7 @@ func (d *Domain) GetLookupPath(r *http.Request) *serving.LookupPath {
return nil
}
- return d.resolve(r).LookupPath
+ return request.LookupPath
}
// IsHTTPSOnly figures out if the request should be handled with HTTPS
diff --git a/internal/serving/request.go b/internal/serving/request.go
index 019939d6..1658af62 100644
--- a/internal/serving/request.go
+++ b/internal/serving/request.go
@@ -11,7 +11,7 @@ type Request struct {
}
// ServeFileHTTP forwards serving request handler to the serving itself
-func (s Request) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
+func (s *Request) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
handler := Handler{
Writer: w,
Request: r,
@@ -23,7 +23,7 @@ func (s Request) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
}
// ServeNotFoundHTTP forwards serving request handler to the serving itself
-func (s Request) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) {
+func (s *Request) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) {
handler := Handler{
Writer: w,
Request: r,
diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go
index 67198232..299c5acb 100644
--- a/internal/source/gitlab/gitlab.go
+++ b/internal/source/gitlab/gitlab.go
@@ -66,7 +66,7 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.Request, error) {
response := g.client.Resolve(r.Context(), host)
if response.Error != nil {
- return nil, response.Error
+ return &serving.Request{Serving: factory.DefaultServing()}, response.Error
}
urlPath := path.Clean(r.URL.Path)