2015-05-05 01:04:17 +08:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mholt/caddy/middleware"
|
|
|
|
"github.com/mholt/caddy/middleware/proxy"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Proxy configures a new Proxy middleware instance.
|
|
|
|
func Proxy(c *Controller) (middleware.Middleware, error) {
|
2015-10-10 06:35:34 +08:00
|
|
|
upstreams, err := proxy.NewStaticUpstreams(c.Dispenser)
|
|
|
|
if err != nil {
|
2015-05-05 01:04:17 +08:00
|
|
|
return nil, err
|
|
|
|
}
|
2015-10-10 06:35:34 +08:00
|
|
|
return func(next middleware.Handler) middleware.Handler {
|
|
|
|
return proxy.Proxy{Next: next, Upstreams: upstreams}
|
|
|
|
}, nil
|
2015-05-05 01:04:17 +08:00
|
|
|
}
|