mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-13 22:51:08 -05:00
4ebff9a130
Merged config and app packages into one called caddy. Abstracted away caddy startup functionality making it easier to embed Caddy in any Go application and use it as a library. Graceful restart (should) now ensure child starts properly. Now piping a gob bundle to child process so that the child can match up inherited listeners to server address. Much cleanup still to do.
17 lines
438 B
Go
17 lines
438 B
Go
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) {
|
|
upstreams, err := proxy.NewStaticUpstreams(c.Dispenser)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return func(next middleware.Handler) middleware.Handler {
|
|
return proxy.Proxy{Next: next, Upstreams: upstreams}
|
|
}, nil
|
|
}
|