mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
Rename handler modules to use http.handlers namespace
This commit is contained in:
parent
9722dbe18a
commit
63674ba081
7 changed files with 18 additions and 10 deletions
|
@ -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) },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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) },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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) },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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) },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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) },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
|
|
@ -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) },
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue