-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Just an issue to track the sub-discussion that was had in #1973, also relating to #550.
See https://caddyserver.com/docs/caddyfile#structure
Caddyfiles allow omitting { }
when there's only a single label (domain/url identifier to serve on). A problem arises when an import
might be used (either by the new glob feature recently merged in, or explicitly in the main Caddyfile). The import
ed files might not be using { }
, so this would cause parsing errors.
The idea is for the fix would be that the parser could artificially wrap the blocks that don't have { }
with those, to avoid the parsing problems.
The tricky bit is figuring out when the label definitions end, because it's allowed for them to be multi-line. For multi-line, each line must end with a ,
(some whitespace following it is allowed) for the label parsing to continue. While label parsing, we should detect the first newline without a ,
and end parsing the label there - which also means we can insert a {
at that time, remember that we did so, and continue parsing. When we reach the end of the file (when import
ing), then we can add a }
if we added a {
earlier.
I think that covers everything. @mholt ?