diff options
author | Matthew Holt <[email protected]> | 2019-10-10 15:38:30 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-10-10 15:38:30 -0600 |
commit | 9c0bf311f93218e8f899cd3c6102868be18a4d1c (patch) | |
tree | de74b8a08c09b26aad05f065e2ba61f857ae7284 /replacer.go | |
parent | 5300949e0def70411fde307afad4c15b6cc22dfd (diff) | |
download | caddy-9c0bf311f93218e8f899cd3c6102868be18a4d1c.tar.gz caddy-9c0bf311f93218e8f899cd3c6102868be18a4d1c.zip |
Miscellaneous cleanups / comments
Diffstat (limited to 'replacer.go')
-rw-r--r-- | replacer.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/replacer.go b/replacer.go index d7beeab69..420259bb1 100644 --- a/replacer.go +++ b/replacer.go @@ -19,6 +19,7 @@ import ( "path/filepath" "runtime" "strings" + "time" ) // Replacer can replace values in strings. @@ -156,11 +157,17 @@ func globalDefaultReplacements(key string) (string, bool) { return runtime.GOOS, true case "system.arch": return runtime.GOARCH, true + case "time.now.common_log": + return nowFunc().Format("02/Jan/2006:15:04:05 -0700"), true } return "", false } +// nowFunc is a variable so tests can change it +// in order to obtain a deterministic time. +var nowFunc = time.Now + // ReplacerCtxKey is the context key for a replacer. const ReplacerCtxKey CtxKey = "replacer" |