Rename handler modules to use http.handlers namespace

This commit is contained in:
Matthew Holt 2019-07-11 22:03:12 -06:00
parent 9722dbe18a
commit 63674ba081
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
7 changed files with 18 additions and 10 deletions

View file

@ -25,7 +25,7 @@ import (
func init() {
caddy.RegisterModule(caddy.Module{
Name: "http.middleware.log",
Name: "http.handlers.log",
New: func() interface{} { return new(Log) },
})
}

View file

@ -24,7 +24,7 @@ import (
func init() {
caddy.RegisterModule(caddy.Module{
Name: "http.middleware.headers",
Name: "http.handlers.headers",
New: func() interface{} { return new(Headers) },
})
}

View file

@ -29,7 +29,7 @@ import (
func init() {
caddy.RegisterModule(caddy.Module{
Name: "http.middleware.markdown",
Name: "http.handlers.markdown",
New: func() interface{} { return new(Markdown) },
})
}

View file

@ -23,7 +23,7 @@ import (
func init() {
caddy.RegisterModule(caddy.Module{
Name: "http.middleware.request_body",
Name: "http.handlers.request_body",
New: func() interface{} { return new(RequestBody) },
})
}

View file

@ -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) },
})
}

View file

@ -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)
)

View file

@ -22,7 +22,7 @@ import (
func init() {
caddy.RegisterModule(caddy.Module{
Name: "http.middleware.table",
Name: "http.handlers.table",
New: func() interface{} { return new(tableMiddleware) },
})