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:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2022-05-04 00:30:34 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-05-05 13:57:09 +0300
commit5da5ac23e2757995661e3ac71c7a1011689e0ace (patch)
treeb94c3c93c6ea653cbccc003f80f35b9514593629 /internal/routing/middleware.go
parent40528a5463f155f70d33dac3573199c0ba3e599d (diff)
Abstract artifact handling to a separate middleware
Diffstat (limited to 'internal/routing/middleware.go')
-rw-r--r--internal/routing/middleware.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/internal/routing/middleware.go b/internal/routing/middleware.go
index de34ec21..712e22a3 100644
--- a/internal/routing/middleware.go
+++ b/internal/routing/middleware.go
@@ -18,7 +18,7 @@ func NewMiddleware(handler http.Handler, s source.Source) 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, d, err := getHostAndDomain(r, s)
+ d, err := getDomain(r, s)
if err != nil && !errors.Is(err, domain.ErrDomainDoesNotExist) {
metrics.DomainsSourceFailures.Inc()
logging.LogRequest(r).WithError(err).Error("could not fetch domain information from a source")
@@ -27,15 +27,13 @@ func NewMiddleware(handler http.Handler, s source.Source) http.Handler {
return
}
- r = domain.ReqWithHostAndDomain(r, host, d)
+ r = domain.ReqWithDomain(r, d)
handler.ServeHTTP(w, r)
})
}
-func getHostAndDomain(r *http.Request, s source.Source) (string, *domain.Domain, error) {
+func getDomain(r *http.Request, s source.Source) (*domain.Domain, error) {
host := request.GetHostWithoutPort(r)
- domain, err := s.GetDomain(r.Context(), host)
-
- return host, domain, err
+ return s.GetDomain(r.Context(), host)
}