diff options
author | WeidiDeng <weidi_deng@icloud.com> | 2022-09-17 04:48:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-16 14:48:55 -0600 |
commit | bffc2587329ca7e1f8a28edae9b5a9bf11e2fc7c (patch) | |
tree | 931fa603617a73b8424f204906ff84ddc2593fe0 /modules/caddyhttp/app.go | |
parent | 616418281b49ed1052ee395b674d8df97c820b11 (diff) |
caddyhttp: Support configuring Server from handler provisioning (#4933)
* configuring http.Server from handlers.
* Minor tweaks
* Run gofmt
Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp/app.go')
-rw-r--r-- | modules/caddyhttp/app.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go index 3edc5b2..0253521 100644 --- a/modules/caddyhttp/app.go +++ b/modules/caddyhttp/app.go @@ -178,7 +178,9 @@ func (app *App) Provision(ctx caddy.Context) error { } // prepare each server + oldContext := ctx.Context for srvName, srv := range app.Servers { + ctx.Context = context.WithValue(oldContext, ServerCtxKey, srv) srv.name = srvName srv.tlsApp = app.tlsApp srv.events = eventsAppIface.(*caddyevents.App) @@ -293,7 +295,7 @@ func (app *App) Provision(ctx caddy.Context) error { srv.IdleTimeout = defaultIdleTimeout } } - + ctx.Context = oldContext return nil } @@ -365,6 +367,7 @@ func (app *App) Start() error { // this TLS config is used by the std lib to choose the actual TLS config for connections // by looking through the connection policies to find the first one that matches tlsCfg := srv.TLSConnPolicies.TLSConfig(app.ctx) + srv.configureServer(srv.server) // enable H2C if configured if srv.protocol("h2c") { |