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-12-10 09:38:29 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-01-20 04:23:45 +0300
commitce03560d89e7315e24e6ade1fcb5ec14f0c82e39 (patch)
tree122ac1384d18dd43124bcb334c409cfd1b50d461 /internal/domain
parent0501f0ad4c1f99de77d0547379c9c30c75cb007c (diff)
Add more test cases for resolver errors
Fix imports and enable test
Diffstat (limited to 'internal/domain')
-rw-r--r--internal/domain/domain.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index f70c4fea..5f32df0b 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -11,12 +11,9 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/client"
)
-// ErrDomainDoesNotExist returned when a domain is not found or when a lookup path
-// for a domain could not be resolved
-var ErrDomainDoesNotExist = errors.New("domain does not exist")
-
// Domain is a domain that gitlab-pages can serve.
type Domain struct {
Name string
@@ -54,7 +51,7 @@ func (d *Domain) isUnconfigured() bool {
}
func (d *Domain) resolve(r *http.Request) (*serving.Request, error) {
if d.Resolver == nil {
- return nil, ErrDomainDoesNotExist
+ return nil, client.ErrDomainDoesNotExist
}
return d.Resolver.Resolve(r)
@@ -145,7 +142,7 @@ func (d *Domain) EnsureCertificate() (*tls.Certificate, error) {
func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
request, err := d.resolve(r)
if err != nil {
- if errors.Is(err, ErrDomainDoesNotExist) {
+ if errors.Is(err, client.ErrDomainDoesNotExist) {
// serve generic 404
httperrors.Serve404(w)
return true
@@ -168,7 +165,7 @@ func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
func (d *Domain) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) {
request, err := d.resolve(r)
if err != nil {
- if errors.Is(err, ErrDomainDoesNotExist) {
+ if errors.Is(err, client.ErrDomainDoesNotExist) {
// serve generic 404
httperrors.Serve404(w)
return