Adjust Caddyfile unmarshal example code

This commit is contained in:
Francis Lavoie 2024-01-01 06:10:29 -05:00
parent 8bf5c00581
commit 847bd6293e
No known key found for this signature in database
GPG key ID: C5204D4F28147FC8
2 changed files with 25 additions and 20 deletions

View file

@ -373,11 +373,15 @@ func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy
// UnmarshalCaddyfile implements caddyfile.Unmarshaler.
func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
for d.Next() {
if !d.Args(&m.Output) {
return d.ArgErr()
}
d.Next() // consume directive name
// require an argument
if !d.NextArg() {
return d.ArgErr()
}
// store the argument
m.Output = d.Val()
return nil
}