Skip to content

Commit fd09f33

Browse files
authored
Merge pull request #13 from owenthereal/caddy_context
Clean up Caddy server context
2 parents 45700cc + a294803 commit fd09f33

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

caddy/server.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,27 @@ type Config struct {
3636
}
3737

3838
func New(cfg Config) candy.ProxyServer {
39-
ctx, cancel := context.WithCancel(context.Background())
40-
4139
return &caddyServer{
4240
cfg: cfg,
4341
apps: candy.NewAppService(candy.AppServiceConfig{
4442
TLDs: cfg.TLDs,
4543
HostRoot: cfg.HostRoot,
4644
}),
47-
ctx: ctx,
48-
cancel: cancel,
4945
}
5046
}
5147

5248
type caddyServer struct {
49+
ctx context.Context
5350
cfg Config
5451
apps *candy.AppService
5552

5653
caddyCfg *caddy.Config
5754
caddyCfgMutex sync.Mutex
58-
59-
ctx context.Context
60-
cancel context.CancelFunc
6155
}
6256

6357
func (c *caddyServer) Run(ctx context.Context) error {
58+
c.ctx = ctx
59+
6460
if err := c.startServer(); err != nil {
6561
return err
6662
}

0 commit comments

Comments
 (0)