diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-07-11 22:03:12 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-07-11 22:03:12 -0600 |
commit | 63674ba081dcf0a1b0ba8d6966fa5874850e3ee3 (patch) | |
tree | a7e9273f7fbb1078cf65ec9997450dd34101a68a /modules/caddyhttp/reverseproxy | |
parent | 9722dbe18a568b8229e07bafb6189a08fa3859e2 (diff) |
Rename handler modules to use http.handlers namespace
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rwxr-xr-x | modules/caddyhttp/reverseproxy/module.go | 2 | ||||
-rwxr-xr-x | modules/caddyhttp/reverseproxy/upstream.go | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/modules/caddyhttp/reverseproxy/module.go b/modules/caddyhttp/reverseproxy/module.go index 72946b7..2e6a338 100755 --- a/modules/caddyhttp/reverseproxy/module.go +++ b/modules/caddyhttp/reverseproxy/module.go @@ -21,7 +21,7 @@ import ( // Register caddy module. func init() { caddy.RegisterModule(caddy.Module{ - Name: "http.responders.reverse_proxy", + Name: "http.handlers.reverse_proxy", New: func() interface{} { return new(LoadBalanced) }, }) } diff --git a/modules/caddyhttp/reverseproxy/upstream.go b/modules/caddyhttp/reverseproxy/upstream.go index a7fea3e..9409ee7 100755 --- a/modules/caddyhttp/reverseproxy/upstream.go +++ b/modules/caddyhttp/reverseproxy/upstream.go @@ -28,6 +28,7 @@ import ( "sync/atomic" "time" + "github.com/caddyserver/caddy/modules/caddyhttp" "github.com/caddyserver/caddy/v2" ) @@ -120,7 +121,7 @@ func NewLoadBalancedReverseProxy(lb *LoadBalanced, ctx caddy.Context) error { } // setup any configured circuit breakers - var cbModule = "http.responders.reverse_proxy.circuit_breaker" + var cbModule = "http.handlers.reverse_proxy.circuit_breaker" var cb CircuitBreaker if uc.CircuitBreaker != nil { @@ -209,9 +210,9 @@ func (lb *LoadBalanced) Provision(ctx caddy.Context) error { return NewLoadBalancedReverseProxy(lb, ctx) } -// ServeHTTP implements the http.Handler interface to dispatch an http request to the proper -// server. -func (lb *LoadBalanced) ServeHTTP(w http.ResponseWriter, r *http.Request) error { +// ServeHTTP implements the caddyhttp.MiddlewareHandler interface to +// dispatch an HTTP request to the proper server. +func (lb *LoadBalanced) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error { // ensure requests don't hang if an upstream does not respond or is not eventually healthy var u *upstream var done bool @@ -440,3 +441,10 @@ func newReverseProxy(target *url.URL, setHealthiness func(bool)) *ReverseProxy { rp.Transport = defaultTransport // use default transport that times out in 5 seconds return rp } + +// Interface guards +var ( + _ caddyhttp.MiddlewareHandler = (*LoadBalanced)(nil) + _ caddy.Provisioner = (*LoadBalanced)(nil) + _ caddy.CleanerUpper = (*LoadBalanced)(nil) +) |