diff options
author | Francis Lavoie <lavofr@gmail.com> | 2021-05-07 18:18:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 16:18:17 -0600 |
commit | 3cf443f0feee50a5de3f31daf79af1b8f70ebc76 (patch) | |
tree | c29945b648f0908d3c8fba14168351715ef4d114 /caddyconfig/httpcaddyfile | |
parent | d4b2f1bcee2190d13bc96aa8da5ea530bd6b9a22 (diff) |
httpcaddyfile: Add `grace_period` global option (#4152)
See https://caddyserver.com/docs/json/apps/http/#grace_period
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r-- | caddyconfig/httpcaddyfile/httptype.go | 15 | ||||
-rw-r--r-- | caddyconfig/httpcaddyfile/options.go | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index 1ccaed2..559d7b7 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -220,9 +220,10 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock, // now that each server is configured, make the HTTP app httpApp := caddyhttp.App{ - HTTPPort: tryInt(options["http_port"], &warnings), - HTTPSPort: tryInt(options["https_port"], &warnings), - Servers: servers, + HTTPPort: tryInt(options["http_port"], &warnings), + HTTPSPort: tryInt(options["https_port"], &warnings), + GracePeriod: tryDuration(options["grace_period"], &warnings), + Servers: servers, } // then make the TLS app @@ -1246,6 +1247,14 @@ func tryString(val interface{}, warnings *[]caddyconfig.Warning) string { return stringVal } +func tryDuration(val interface{}, warnings *[]caddyconfig.Warning) caddy.Duration { + durationVal, ok := val.(caddy.Duration) + if val != nil && !ok && warnings != nil { + *warnings = append(*warnings, caddyconfig.Warning{Message: "not a duration type"}) + } + return durationVal +} + // sliceContains returns true if needle is in haystack. func sliceContains(haystack []string, needle string) bool { for _, s := range haystack { diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go index d95496c..905ecae 100644 --- a/caddyconfig/httpcaddyfile/options.go +++ b/caddyconfig/httpcaddyfile/options.go @@ -29,10 +29,11 @@ func init() { RegisterGlobalOption("debug", parseOptTrue) RegisterGlobalOption("http_port", parseOptHTTPPort) RegisterGlobalOption("https_port", parseOptHTTPSPort) + RegisterGlobalOption("grace_period", parseOptDuration) RegisterGlobalOption("default_sni", parseOptSingleString) RegisterGlobalOption("order", parseOptOrder) RegisterGlobalOption("storage", parseOptStorage) - RegisterGlobalOption("storage_clean_interval", parseOptStorageCleanInterval) + RegisterGlobalOption("storage_clean_interval", parseOptDuration) RegisterGlobalOption("acme_ca", parseOptSingleString) RegisterGlobalOption("acme_ca_root", parseOptSingleString) RegisterGlobalOption("acme_dns", parseOptACMEDNS) @@ -178,7 +179,7 @@ func parseOptStorage(d *caddyfile.Dispenser, _ interface{}) (interface{}, error) return storage, nil } -func parseOptStorageCleanInterval(d *caddyfile.Dispenser, _ interface{}) (interface{}, error) { +func parseOptDuration(d *caddyfile.Dispenser, _ interface{}) (interface{}, error) { if !d.Next() { // consume option name return nil, d.ArgErr() } |