diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-12-09 12:16:08 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-01-14 02:44:13 +0300 |
commit | b82ad758ccbfae66c719fedebdfa3f74d27ab215 (patch) | |
tree | 055e3c71c3c8ea1514cbd7fcd79c784a571e3c24 /app.go | |
parent | f2d6fa65a7e3cefab6e35a7807b5f95f4981cedb (diff) |
Move error to domain package
Define ErrDomainDoesNotExist in the domain package so it can be returned
by the Resolver and handled appropriatley.
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2,6 +2,7 @@ package main import ( "crypto/tls" + "errors" "fmt" "net" "net/http" @@ -150,8 +151,8 @@ func (a *theApp) routingMiddleware(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // if we could not retrieve a domain from domains source we break the // middleware chain and simply respond with 502 after logging this - host, domain, err := a.getHostAndDomain(r) - if err != nil { + host, d, err := a.getHostAndDomain(r) + if err != nil && !errors.Is(err, domain.ErrDomainDoesNotExist) { metrics.DomainsSourceFailures.Inc() log.WithError(err).Error("could not fetch domain information from a source") @@ -159,7 +160,7 @@ func (a *theApp) routingMiddleware(handler http.Handler) http.Handler { return } - r = request.WithHostAndDomain(r, host, domain) + r = request.WithHostAndDomain(r, host, d) handler.ServeHTTP(w, r) }) |