diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-04-22 14:44:53 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-04-22 14:44:53 +0300 |
commit | 83fd26e1ea6d443d7b6e3f99fec7f3f8fb942731 (patch) | |
tree | a9ba8162a1aeb10fccbb2213dd351429b95ced2b /app.go | |
parent | 60864cb8ebd9b79abc57fd29d21241cdacb21efd (diff) |
Move https middleware to internal/handlers
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -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 { |