diff options
Diffstat (limited to 'replacer.go')
-rw-r--r-- | replacer.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/replacer.go b/replacer.go index 7f97f34..5d33b7f 100644 --- a/replacer.go +++ b/replacer.go @@ -16,6 +16,7 @@ package caddy import ( "fmt" + "net/http" "os" "path/filepath" "runtime" @@ -130,7 +131,8 @@ func (r *Replacer) ReplaceFunc(input string, f ReplacementFunc) (string, error) func (r *Replacer) replace(input, empty string, treatUnknownAsEmpty, errOnEmpty, errOnUnknown bool, - f ReplacementFunc) (string, error) { + f ReplacementFunc, +) (string, error) { if !strings.Contains(input, string(phOpen)) { return input, nil } @@ -316,6 +318,11 @@ func globalDefaultReplacements(key string) (any, bool) { return runtime.GOARCH, true case "time.now": return nowFunc(), true + case "time.now.http": + // According to the comment for http.TimeFormat, the timezone must be in UTC + // to generate the correct format. + // https://github.com/caddyserver/caddy/issues/5773 + return nowFunc().UTC().Format(http.TimeFormat), true case "time.now.common_log": return nowFunc().Format("02/Jan/2006:15:04:05 -0700"), true case "time.now.year": |