diff options
author | Matthew Holt <[email protected]> | 2020-05-01 09:34:32 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2020-05-01 09:34:32 -0600 |
commit | bca610fbde82c4b45526dd526d7ddfa6e3bdac70 (patch) | |
tree | e48afd329e3661966533ddf8d3c141a9d1d38f64 /modules/filestorage | |
parent | 1fa8c185a893381c06960142d35a557787f61bdc (diff) | |
download | caddy-bca610fbde82c4b45526dd526d7ddfa6e3bdac70.tar.gz caddy-bca610fbde82c4b45526dd526d7ddfa6e3bdac70.zip |
httpcaddyfile: Minor fixes to parsing storage options
Diffstat (limited to 'modules/filestorage')
-rw-r--r-- | modules/filestorage/filestorage.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/modules/filestorage/filestorage.go b/modules/filestorage/filestorage.go index 6e688ef0f..629dc27ed 100644 --- a/modules/filestorage/filestorage.go +++ b/modules/filestorage/filestorage.go @@ -48,15 +48,32 @@ func (s *FileStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { if !d.Next() { return d.Err("expected tokens") } - for nesting := d.Nesting(); d.NextBlock(nesting); { - if !d.NextArg() { - return d.ArgErr() - } + if d.NextArg() { s.Root = d.Val() - if d.NextArg() { - return d.ArgErr() + } + if d.NextArg() { + return d.ArgErr() + } + for nesting := d.Nesting(); d.NextBlock(nesting); { + switch d.Val() { + case "root": + if !d.NextArg() { + return d.ArgErr() + } + if s.Root != "" { + return d.Err("root already set") + } + s.Root = d.Val() + if d.NextArg() { + return d.ArgErr() + } + default: + return d.Errf("unrecognized parameter '%s'", d.Val()) } } + if s.Root == "" { + return d.Err("missing root path (to use default, omit storage config entirely)") + } return nil } |