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
path: root/app.go
diff options
context:
space:
mode:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2022-04-22 14:44:53 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-04-22 14:44:53 +0300
commit83fd26e1ea6d443d7b6e3f99fec7f3f8fb942731 (patch)
treea9ba8162a1aeb10fccbb2213dd351429b95ced2b /app.go
parent60864cb8ebd9b79abc57fd29d21241cdacb21efd (diff)
Move https middleware to internal/handlers
Diffstat (limited to 'app.go')
-rw-r--r--app.go17
1 files changed, 3 insertions, 14 deletions
diff --git a/app.go b/app.go
index 12228c53..c7012ad5 100644
--- a/app.go
+++ b/app.go
@@ -182,17 +182,6 @@ func (a *theApp) auxiliaryMiddleware(handler http.Handler) http.Handler {
})
}
-func (a *theApp) httpsRedirectMiddleware(handler http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if a.config.General.RedirectHTTP && !request.IsHTTPS(r) {
- a.redirectToHTTPS(w, r, http.StatusTemporaryRedirect)
- return
- }
-
- handler.ServeHTTP(w, r)
- })
-}
-
// serveFileOrNotFoundHandler will serve static content or
// return a 404 Not Found response
func (a *theApp) serveFileOrNotFoundHandler() http.Handler {
@@ -252,6 +241,9 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
handler = routing.NewMiddleware(handler, a.source)
+ // Add auto redirect
+ handler = handlers.HTTPSRedirectMiddleware(handler, a.config.General.RedirectHTTP)
+
handler = handlers.Ratelimiter(handler, &a.config.RateLimit)
// Health Check
@@ -260,9 +252,6 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
// Custom response headers
handler = customheaders.NewMiddleware(handler, a.CustomHeaders)
- // Add auto redirect
- handler = a.httpsRedirectMiddleware(handler)
-
// Correlation ID injection middleware
var correlationOpts []correlation.InboundHandlerOption
if a.config.General.PropagateCorrelationID {