diff options
-rw-r--r-- | app.go | 6 | ||||
-rw-r--r-- | internal/middleware/headers.go (renamed from internal/config/headers.go) | 5 | ||||
-rw-r--r-- | internal/middleware/headers_test.go (renamed from internal/config/headers_test.go) | 2 |
3 files changed, 6 insertions, 7 deletions
@@ -21,11 +21,11 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/acme" "gitlab.com/gitlab-org/gitlab-pages/internal/artifact" "gitlab.com/gitlab-org/gitlab-pages/internal/auth" - headerConfig "gitlab.com/gitlab-org/gitlab-pages/internal/config" "gitlab.com/gitlab-org/gitlab-pages/internal/domain" "gitlab.com/gitlab-org/gitlab-pages/internal/handlers" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" "gitlab.com/gitlab-org/gitlab-pages/internal/logging" + "gitlab.com/gitlab-org/gitlab-pages/internal/middleware" "gitlab.com/gitlab-org/gitlab-pages/internal/netutil" "gitlab.com/gitlab-org/gitlab-pages/internal/request" "gitlab.com/gitlab-org/gitlab-pages/internal/source" @@ -186,7 +186,7 @@ func (a *theApp) healthCheckMiddleware(handler http.Handler) (http.Handler, erro // customHeadersMiddleware will inject custom headers into the response func (a *theApp) customHeadersMiddleware(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - headerConfig.AddCustomHeaders(w, a.CustomHeaders) + middleware.AddCustomHeaders(w, a.CustomHeaders) handler.ServeHTTP(w, r) }) @@ -493,7 +493,7 @@ func runApp(config appConfig) { } if len(config.CustomHeaders) != 0 { - customHeaders, err := headerConfig.ParseHeaderString(config.CustomHeaders) + customHeaders, err := middleware.ParseHeaderString(config.CustomHeaders) if err != nil { log.WithError(err).Fatal("Unable to parse header string") } diff --git a/internal/config/headers.go b/internal/middleware/headers.go index d415b21d..77b008f3 100644 --- a/internal/config/headers.go +++ b/internal/middleware/headers.go @@ -1,4 +1,4 @@ -package config +package middleware import ( "errors" @@ -9,13 +9,12 @@ import ( var errInvalidHeaderParameter = errors.New("invalid syntax specified as header parameter") // AddCustomHeaders adds a map of Headers to a Response -func AddCustomHeaders(w http.ResponseWriter, headers http.Header) error { +func AddCustomHeaders(w http.ResponseWriter, headers http.Header) { for k, v := range headers { for _, value := range v { w.Header().Add(k, value) } } - return nil } // ParseHeaderString parses a string of key values into a map diff --git a/internal/config/headers_test.go b/internal/middleware/headers_test.go index 44afd470..17d31b50 100644 --- a/internal/config/headers_test.go +++ b/internal/middleware/headers_test.go @@ -1,4 +1,4 @@ -package config +package middleware import ( "net/http/httptest" |