improve flow
This commit is contained in:
parent
c76d7b4d12
commit
90d442b611
@ -187,11 +187,10 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
}
|
||||
var (
|
||||
containerName string
|
||||
host, _, _ = net.SplitHostPort(r.RemoteAddr)
|
||||
ip = net.ParseIP(host)
|
||||
)
|
||||
for containerName, mr = range containerMethodRegex {
|
||||
resolvedIPs, err := net.LookupIP(containerName)
|
||||
@ -200,7 +199,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
for _, resolvedIP := range resolvedIPs {
|
||||
if resolvedIP.Equal(ip) {
|
||||
if resolvedIP.Equal(net.ParseIP(host)) {
|
||||
var req *regexp.Regexp
|
||||
req, ok = mr[r.Method]
|
||||
if !ok {
|
||||
@ -242,7 +241,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
log.Warn().
|
||||
Str("remote_addr", r.RemoteAddr).
|
||||
Str("method", r.Method).
|
||||
@ -251,6 +250,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
Msg("this error may be transient due to the unavailability of one of the services")
|
||||
http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable)
|
||||
return
|
||||
*/
|
||||
}
|
||||
|
||||
// checkMethodPath executes the regular expression on the path of the HTTP request if and only if
|
||||
|
Loading…
x
Reference in New Issue
Block a user