diff --git a/command/serve.go b/command/serve.go index bdd721b..379b6c7 100644 --- a/command/serve.go +++ b/command/serve.go @@ -151,9 +151,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Debug().Str("remote_addr", r.RemoteAddr).Str("http_method", r.Method).Str("path", r.URL.Path).Msg("incoming request") mr, ok := containerMethodRegex["*"] if ok { - fmt.Println("here 1") if err := checkMethodPath(w, r, mr); err != nil { - fmt.Println("failed here 1") log.Err(err).Send() return } @@ -167,29 +165,21 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { resolvedIPs, err := net.LookupIP(containerName) if err != nil { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) - fmt.Println("failed here 2") log.Err(err).Send() return } - fmt.Printf("count of resolved IPs: %d\n", len(resolvedIPs)) for _, resolvedIP := range resolvedIPs { - fmt.Printf("resolvedIP: %s -- IP: %s", resolvedIP.String(), ip.String()) if resolvedIP.Equal(ip) { - // fmt.Printf("%s == %s\n", resolvedIP.String(), ip.String()) if err = checkMethodPath(w, r, mr); err != nil { - fmt.Println("failed here 3") log.Err(err).Send() return } - fmt.Println("here 2") + ph.rp.ServeHTTP(w, r) } - fmt.Println("here 3") } - fmt.Println("here 4") } - fmt.Println("here 5") } - ph.rp.ServeHTTP(w, r) + return } // checkMethodPath executes the regular expression on the path of the HTTP request if and only if @@ -197,11 +187,9 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func checkMethodPath(w http.ResponseWriter, r *http.Request, mr methodRegex) error { req, ok := mr[r.Method] if !ok { - fmt.Printf("%s is not a registered HTTP method\n", r.Method) http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) return ErrHTTPMethodNotAllowed{httpMethod: r.Method} } - log.Debug().Msgf("%s is a registered HTTP method", r.Method) if !req.MatchString(r.URL.Path) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return ErrNoMatch{ @@ -209,7 +197,6 @@ func checkMethodPath(w http.ResponseWriter, r *http.Request, mr methodRegex) err httpMethod: r.Method, } } - log.Debug().Msgf("%s matches %s", r.URL.Path, req.String()) return nil }