mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
25 lines
547 B
Go
25 lines
547 B
Go
package proxy
|
|
|
|
import (
|
|
"github.com/mholt/caddy"
|
|
"github.com/mholt/caddy/caddyhttp/httpserver"
|
|
)
|
|
|
|
func init() {
|
|
caddy.RegisterPlugin("proxy", caddy.Plugin{
|
|
ServerType: "http",
|
|
Action: setup,
|
|
})
|
|
}
|
|
|
|
// setup configures a new Proxy middleware instance.
|
|
func setup(c *caddy.Controller) error {
|
|
upstreams, err := NewStaticUpstreams(c.Dispenser)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
|
|
return Proxy{Next: next, Upstreams: upstreams}
|
|
})
|
|
return nil
|
|
}
|