From ec887ccb93a8022c5f6b33f7808433b23ee8ea58 Mon Sep 17 00:00:00 2001 From: Adrien PONSIN Date: Thu, 17 Apr 2025 15:00:32 +0200 Subject: [PATCH] remove useless return --- command/serve.go | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/command/serve.go b/command/serve.go index b4a65c3..0607bfc 100644 --- a/command/serve.go +++ b/command/serve.go @@ -152,24 +152,6 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { mr, ok := containerMethodRegex["*"] if ok { ph.checkMethodAndRegex(w, r, mr) - /* - var req *regexp.Regexp - req, ok = mr[r.Method] - if !ok { - logDeniedRequest(r, http.StatusMethodNotAllowed, "this HTTP method is not in the list of those authorized for this container") - - http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) - return - } - if !req.MatchString(r.URL.Path) { - logDeniedRequest(r, http.StatusForbidden, "this path does not match any regular expression for this HTTP method") - http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) - return - } - logAuthorizedRequest(r, "", "incoming request matches a registered regular expression") - ph.rp.ServeHTTP(w, r) - return - */ } var ( containerName string @@ -183,24 +165,6 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { for _, resolvedIP := range resolvedIPs { if resolvedIP.Equal(net.ParseIP(host)) { ph.checkMethodAndRegex(w, r, mr) - /* - var req *regexp.Regexp - req, ok = mr[r.Method] - if !ok { - logDeniedRequest(r, http.StatusMethodNotAllowed, "this HTTP method is not in the list of those authorized for this container") - http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) - return - } - if !req.MatchString(r.URL.Path) { - logDeniedRequest(r, http.StatusForbidden, "this path does not match any regular expression for this HTTP method") - http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) - return - } - logAuthorizedRequest(r, containerName, "incoming request matches a registered regular expression") - - ph.rp.ServeHTTP(w, r) - return - */ } } } @@ -242,17 +206,7 @@ func (ph *ProxyHandler) checkMethodAndRegex(w http.ResponseWriter, r *http.Reque return } logAuthorizedRequest(r, "", "incoming request matches a registered regular expression") - /* - log.Info(). - Str("remote_addr", r.RemoteAddr). - Str("method", r.Method). - Str("path", r.URL.Path). - Int("status_code", http.StatusOK). - Str("status_text", http.StatusText(http.StatusOK)). - Msg("incoming request matches a registered regular expression") - */ ph.rp.ServeHTTP(w, r) - return } // action is executed when the ServeCmd command is called.