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>2021-10-25 03:50:40 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2021-10-25 12:44:29 +0300
commita05ea2141704d8aeaa21e45365efb9e153e6eb93 (patch)
treea68586b36b8cae8f23270fc1bdbb74a69e8f7131 /internal/logging
parent1a1adbaf869ed651aae3671c507f726a64b1d7ca (diff)
refactor: remove domain from request
Diffstat (limited to 'internal/logging')
-rw-r--r--internal/logging/logging.go23
-rw-r--r--internal/logging/logging_test.go4
2 files changed, 6 insertions, 21 deletions
diff --git a/internal/logging/logging.go b/internal/logging/logging.go
index f485b20b..d2d758db 100644
--- a/internal/logging/logging.go
+++ b/internal/logging/logging.go
@@ -51,21 +51,6 @@ func getAccessLogger(format string) (*logrus.Logger, error) {
return accessLogger, nil
}
-// getExtraLogFields is used to inject additional fields into the
-// HTTP access logger middleware.
-func getExtraLogFields(r *http.Request) log.Fields {
- logFields := log.Fields{
- "pages_https": request.IsHTTPS(r),
- "pages_host": request.GetHost(r),
- }
-
- for name, value := range request.GetDomain(r).LogFields(r) {
- logFields[name] = value
- }
-
- return logFields
-}
-
// BasicAccessLogger configures the GitLab pages basic HTTP access logger middleware
func BasicAccessLogger(handler http.Handler, format string, extraFields log.ExtraFieldsGeneratorFunc) (http.Handler, error) {
accessLogger, err := getAccessLogger(format)
@@ -98,10 +83,10 @@ func enrichExtraFields(extraFields log.ExtraFieldsGeneratorFunc) log.ExtraFields
}
}
-// AccessLogger configures the GitLab pages HTTP access logger middleware with extra log fields
-func AccessLogger(handler http.Handler, format string) (http.Handler, error) {
- return BasicAccessLogger(handler, format, getExtraLogFields)
-}
+//// AccessLogger configures the GitLab pages HTTP access logger middleware with extra log fields
+//func AccessLogger(handler http.Handler, format string) (http.Handler, error) {
+// return BasicAccessLogger(handler, format, getExtraLogFields)
+//}
// LogRequest will inject request host and path to the logged messages
func LogRequest(r *http.Request) *logrus.Entry {
diff --git a/internal/logging/logging_test.go b/internal/logging/logging_test.go
index df8c3013..fe157e88 100644
--- a/internal/logging/logging_test.go
+++ b/internal/logging/logging_test.go
@@ -72,9 +72,9 @@ func TestGetExtraLogFields(t *testing.T) {
require.NoError(t, err)
req.URL.Scheme = tt.scheme
- req = request.WithHostAndDomain(req, tt.host, domainWithResolver)
+ req = domain.ReqWithHostAndDomain(req, tt.host, domainWithResolver)
- got := getExtraLogFields(req)
+ got := domain.LogFields(req)
require.Equal(t, tt.expectedHTTPS, got["pages_https"])
require.Equal(t, tt.expectedHost, got["pages_host"])
require.Equal(t, tt.expectedProjectID, got["pages_project_id"])