remove useless return

This commit is contained in:
Adrien PONSIN 2025-04-17 15:00:32 +02:00
parent 3829a46f87
commit ec887ccb93
No known key found for this signature in database
GPG Key ID: 7B4D4A32C05C475E

View File

@ -152,24 +152,6 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
mr, ok := containerMethodRegex["*"] mr, ok := containerMethodRegex["*"]
if ok { if ok {
ph.checkMethodAndRegex(w, r, mr) 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 ( var (
containerName string containerName string
@ -183,24 +165,6 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for _, resolvedIP := range resolvedIPs { for _, resolvedIP := range resolvedIPs {
if resolvedIP.Equal(net.ParseIP(host)) { if resolvedIP.Equal(net.ParseIP(host)) {
ph.checkMethodAndRegex(w, r, mr) 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 return
} }
logAuthorizedRequest(r, "", "incoming request matches a registered regular expression") 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) ph.rp.ServeHTTP(w, r)
return
} }
// action is executed when the ServeCmd command is called. // action is executed when the ServeCmd command is called.