From 908fa5e103eeb9ca13ec22a31a8814d20cfcc8ea Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 27 Aug 2024 10:48:59 +0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Francis Lavoie --- modules/caddyhttp/reverseproxy/caddyfile.go | 16 +++++++++------- modules/caddyhttp/reverseproxy/httptransport.go | 8 ++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go index 59a7ff75..4e8ea674 100644 --- a/modules/caddyhttp/reverseproxy/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/caddyfile.go @@ -980,9 +980,9 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error // read_buffer // write_buffer // max_response_header -// network_proxy { -// ... -// } +// network_proxy { +// ... +// } // dial_timeout // dial_fallback_delay // response_header_timeout @@ -993,9 +993,9 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error // tls_insecure_skip_verify // tls_timeout // tls_trusted_ca_certs -// tls_trust_pool { -// ... -// } +// tls_trust_pool { +// ... +// } // tls_server_name // tls_renegotiation // tls_except_ports @@ -1074,12 +1074,13 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } case "forward_proxy_url": - caddy.Log().Warn("The 'forward_proxy_url' field is deprecated. Use the 'network_proxy' field instead.") + caddy.Log().Warn("The 'forward_proxy_url' field is deprecated. Use 'network_proxy url ' instead.") if !d.NextArg() { return d.ArgErr() } h.ForwardProxyURL = d.Val() + case "network_proxy": if !d.NextArg() { return d.ArgErr() @@ -1091,6 +1092,7 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { return err } h.NetworkProxyRaw = caddyconfig.JSONModuleObject(unm, "from", modStem, nil) + case "dial_timeout": if !d.NextArg() { return d.ArgErr() diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go index e9e31b1c..1c8911a3 100644 --- a/modules/caddyhttp/reverseproxy/httptransport.go +++ b/modules/caddyhttp/reverseproxy/httptransport.go @@ -145,15 +145,15 @@ type HTTPTransport struct { // requests to the upstream. See [http.Transport.Proxy](https://pkg.go.dev/net/http#Transport.Proxy) // for information regarding supported protocols. // - // Providing a value to this parameter results in - // requests flowing through the reverse_proxy in the following - // way: + // Providing a value to this parameter results in requests + // flowing through the reverse_proxy in the following way: // // User Agent -> // reverse_proxy -> // [proxy provided by the module] -> upstream // - // If nil/empty, default to reading the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`. + // If nil, defaults to reading the `HTTP_PROXY`, + // `HTTPS_PROXY`, and `NO_PROXY` environment variables. NetworkProxyRaw json.RawMessage `json:"network_proxy,omitempty" caddy:"namespace=caddy.network_proxy.source inline_key=from"` h2cTransport *http2.Transport