summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-03-22 10:47:21 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-03-22 10:47:21 -0600
commit79cbe7bfd06565d0e7ab0717119f78960ed54c08 (patch)
tree4f2b333e5419ad3c3a7c0cc4ea4398afbc61c340 /caddyconfig/httpcaddyfile
parent55b4c12e0404347828ed691594d1f8ae8228c598 (diff)
httpcaddyfile: Add 'vars' directive
See discussion in #4650
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/builtins.go8
-rw-r--r--caddyconfig/httpcaddyfile/directives.go1
2 files changed, 9 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go
index e1430d0..e65039d 100644
--- a/caddyconfig/httpcaddyfile/builtins.go
+++ b/caddyconfig/httpcaddyfile/builtins.go
@@ -39,6 +39,7 @@ func init() {
RegisterDirective("bind", parseBind)
RegisterDirective("tls", parseTLS)
RegisterHandlerDirective("root", parseRoot)
+ RegisterHandlerDirective("vars", parseVars)
RegisterHandlerDirective("redir", parseRedir)
RegisterHandlerDirective("respond", parseRespond)
RegisterHandlerDirective("abort", parseAbort)
@@ -530,6 +531,13 @@ func parseRoot(h Helper) (caddyhttp.MiddlewareHandler, error) {
return caddyhttp.VarsMiddleware{"root": root}, nil
}
+// parseVars parses the vars directive. See its UnmarshalCaddyfile method for syntax.
+func parseVars(h Helper) (caddyhttp.MiddlewareHandler, error) {
+ v := new(caddyhttp.VarsMiddleware)
+ err := v.UnmarshalCaddyfile(h.Dispenser)
+ return v, err
+}
+
// parseRedir parses the redir directive. Syntax:
//
// redir [<matcher>] <to> [<code>]
diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go
index aac4f1f..425bf19 100644
--- a/caddyconfig/httpcaddyfile/directives.go
+++ b/caddyconfig/httpcaddyfile/directives.go
@@ -40,6 +40,7 @@ var directiveOrder = []string{
"tracing",
"map",
+ "vars",
"root",
"header",