MCPcopy Create free account
hub / github.com/pydio/cells / ReloadProxy

Method ReloadProxy

common/server/caddy/api/server.go:95–117  ·  view source on GitHub ↗
(reg registry.Registry)

Source from the content-addressed store, hash-verified

93}
94
95func (s *Server) ReloadProxy(reg registry.Registry) error {
96 er := s.balancer.Build(reg)
97 if er != nil {
98 return er
99 }
100 caddyConfig, _, er := caddy.ResolveSites(s.RootContext(), func(endpoint string) ([]*url.URL, error) {
101 return s.balancer.ListEndpointTargets(endpoint, true)
102 }, true)
103 if er != nil {
104 return er
105 }
106
107 reader := bytes.NewReader(caddyConfig)
108 resp, er := http.Post(s.caddyApi+"/load", "application/json", reader)
109 if er != nil {
110 return er
111 }
112 if resp.StatusCode != 200 {
113 return fmt.Errorf("cannot post to caddy server, code was %d", resp.StatusCode)
114 }
115 return nil
116
117}
118
119func (s *Server) Stop() error {
120 // Todo - shall we post an empty config to the remote

Callers 1

RawServeMethod · 0.95

Calls 5

ResolveSitesFunction · 0.92
BuildMethod · 0.65
RootContextMethod · 0.65
ListEndpointTargetsMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected