summaryrefslogtreecommitdiff
path: root/replacer.go
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2023-11-01 17:57:48 +0100
committerTom Barrett <tom@tombarrett.xyz>2023-11-01 18:11:33 +0100
commit240c3d1338415e5d82ef7ca0e52c4284be6441bd (patch)
tree4b0ee5d208c2cdffa78d65f1b0abe0ec85f15652 /replacer.go
parent73e78ab226f21e6c6c68961af88c4ab9c746f4f4 (diff)
parent0e204b730aa2b1fa0835336b1117eff8c420f713 (diff)
vbump to v2.7.5HEADcaddy-cgi
Diffstat (limited to 'replacer.go')
-rw-r--r--replacer.go9
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":