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:
authorAlessio Caiazza <acaiazza@gitlab.com>2020-03-04 15:56:25 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2020-03-04 15:56:25 +0300
commitfda9c63431b0a75befb13e5254154ca658f53a8c (patch)
treee92cf4f7634d07c20e0cece9e570d2eaffb1ecf4 /internal
parent3a304fef80e76b5f7803b720c76924f73a8dab64 (diff)
parentd12e59eefc3ce15ba9dac808c5e345bf26ad5d45 (diff)
Merge branch '350-healthcheck-middleware' into 'master'
Extract health check in its own middleware See merge request gitlab-org/gitlab-pages!247
Diffstat (limited to 'internal')
-rw-r--r--internal/logging/logging.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/internal/logging/logging.go b/internal/logging/logging.go
index 28c43c2e..4ba86985 100644
--- a/internal/logging/logging.go
+++ b/internal/logging/logging.go
@@ -65,20 +65,33 @@ func getExtraLogFields(r *http.Request) log.Fields {
}
}
-// AccessLogger configures the GitLab pages HTTP access logger middleware
-func AccessLogger(handler http.Handler, format string) (http.Handler, error) {
-
+// 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)
if err != nil {
return nil, err
}
+ if extraFields == nil {
+ extraFields = func(r *http.Request) log.Fields {
+ return log.Fields{
+ "pages_https": request.IsHTTPS(r),
+ "pages_host": r.Host,
+ }
+ }
+ }
+
return log.AccessLogger(handler,
- log.WithExtraFields(getExtraLogFields),
+ log.WithExtraFields(extraFields),
log.WithAccessLogger(accessLogger),
), nil
}
+// 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 {
return log.WithFields(log.Fields{