summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-10 19:21:52 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-10 19:21:52 -0600
commit2459c292a4d6fb0552eb9be3cecd955093ed853b (patch)
tree5f10e9c5d8e9250e83f7282e8d57d386cb54e8a6 /modules/caddyhttp/reverseproxy
parent0cf592fa2e0d2fff8e9379095bbe17f7c8cbd4f2 (diff)
caddyfile: Improve Dispenser.NextBlock() to support nesting
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go5
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go52
2 files changed, 29 insertions, 28 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index ffa3ca0..56b3a5a 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -81,7 +81,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
})
}
- for d.NextBlock() {
+ for d.NextBlock(0) {
switch d.Val() {
case "to":
args := d.RemainingArgs()
@@ -343,7 +343,6 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if !ok {
return d.Errf("transport module '%s' is not a Caddyfile unmarshaler", mod.Name)
}
- d.Next() // consume the module name token
err = unm.UnmarshalCaddyfile(d.NewFromNextTokens())
if err != nil {
return err
@@ -377,7 +376,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
// }
//
func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
- for d.NextBlock() {
+ for d.NextBlock(0) {
switch d.Val() {
case "read_buffer":
if !d.NextArg() {
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
index 1476d60..fd82c5a 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
@@ -39,32 +39,34 @@ func init() {
// }
//
func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
- for d.NextBlock() {
- switch d.Val() {
- case "root":
- if !d.NextArg() {
- return d.ArgErr()
+ for d.Next() {
+ for d.NextBlock(0) {
+ switch d.Val() {
+ case "root":
+ if !d.NextArg() {
+ return d.ArgErr()
+ }
+ t.Root = d.Val()
+
+ case "split":
+ if !d.NextArg() {
+ return d.ArgErr()
+ }
+ t.SplitPath = d.Val()
+
+ case "env":
+ args := d.RemainingArgs()
+ if len(args) != 2 {
+ return d.ArgErr()
+ }
+ if t.EnvVars == nil {
+ t.EnvVars = make(map[string]string)
+ }
+ t.EnvVars[args[0]] = args[1]
+
+ default:
+ return d.Errf("unrecognized subdirective %s", d.Val())
}
- t.Root = d.Val()
-
- case "split":
- if !d.NextArg() {
- return d.ArgErr()
- }
- t.SplitPath = d.Val()
-
- case "env":
- args := d.RemainingArgs()
- if len(args) != 2 {
- return d.ArgErr()
- }
- if t.EnvVars == nil {
- t.EnvVars = make(map[string]string)
- }
- t.EnvVars[args[0]] = args[1]
-
- default:
- return d.Errf("unrecognized subdirective %s", d.Val())
}
}
return nil