Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverseproxy: Emit debug log before checking error (#3425)
This way the upstream request will always be available even if it failed
Matthew Holt committed
May 18, 2020 at 13:50 UTC
812278acd8a5c46b44fdf92ea5df4d6a51eff7be
1 file changed
+3
-4
modules/caddyhttp/reverseproxy/reverseproxy.go
+3
-4
@@ -465,10 +465,6 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, di Dia
465
start := time.Now()
466
res, err := h.Transport.RoundTrip(req)
467
duration := time.Since(start)
468
- if err != nil {
469
- return err
470
- }
471
-
468
h.logger.Debug("upstream roundtrip",
469
zap.String("upstream", di.Upstream.String()),
470
zap.Object("request", caddyhttp.LoggableHTTPRequest{Request: req}),
@@ -476,6 +472,9 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, di Dia
472
zap.Duration("duration", duration),
473
zap.Int("status", res.StatusCode),
474
)
475
+ if err != nil {
476
+ return err
477
+ }
478
479
// update circuit breaker on current conditions
480
if di.Upstream.cb != nil {