From 2459c292a4d6fb0552eb9be3cecd955093ed853b Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 10 Sep 2019 19:21:52 -0600 Subject: caddyfile: Improve Dispenser.NextBlock() to support nesting --- caddyconfig/httpcaddyfile/builtins.go | 2 +- caddyconfig/httpcaddyfile/handlers.go | 2 +- caddyconfig/httpcaddyfile/options.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'caddyconfig/httpcaddyfile') diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go index db2eee5..0ac436e 100644 --- a/caddyconfig/httpcaddyfile/builtins.go +++ b/caddyconfig/httpcaddyfile/builtins.go @@ -107,7 +107,7 @@ func parseTLS(h Helper) ([]ConfigValue, error) { } var hasBlock bool - for h.NextBlock() { + for h.NextBlock(0) { hasBlock = true switch h.Val() { diff --git a/caddyconfig/httpcaddyfile/handlers.go b/caddyconfig/httpcaddyfile/handlers.go index 9a29e97..e133028 100644 --- a/caddyconfig/httpcaddyfile/handlers.go +++ b/caddyconfig/httpcaddyfile/handlers.go @@ -28,7 +28,7 @@ func (st *ServerType) parseMatcherDefinitions(d *caddyfile.Dispenser) (map[strin matchers := make(map[string]map[string]json.RawMessage) for d.Next() { definitionName := d.Val() - for d.NextBlock() { + for nesting := d.Nesting(); d.NextBlock(nesting); { matcherName := d.Val() mod, err := caddy.GetModule("http.matchers." + matcherName) if err != nil { diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go index f99ce51..d9fb4b0 100644 --- a/caddyconfig/httpcaddyfile/options.go +++ b/caddyconfig/httpcaddyfile/options.go @@ -60,10 +60,10 @@ func parseHandlerOrder(d *caddyfile.Dispenser) ([]string, error) { if len(order) == 1 && order[0] == "appearance" { return []string{"appearance"}, nil } - if len(order) > 0 && d.NextBlock() { + if len(order) > 0 && d.NextBlock(0) { return nil, d.Err("cannot open block if there are arguments") } - for d.NextBlock() { + for d.NextBlock(0) { order = append(order, d.Val()) if d.NextArg() { return nil, d.ArgErr() -- cgit v1.2.3