aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddyconfig/caddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-01-23 19:36:59 -0500
committerGitHub <[email protected]>2024-01-23 19:36:59 -0500
commit750d0b83319ac0ea6b7f057b8270c19404c3d6fa (patch)
treed0c3fb610cde8ae9d73a0a2caba94542af099770 /caddyconfig/caddyfile
parent54823f52bc9aed66a1a37f820daf6e494181211a (diff)
downloadcaddy-750d0b83319ac0ea6b7f057b8270c19404c3d6fa.tar.gz
caddy-750d0b83319ac0ea6b7f057b8270c19404c3d6fa.zip
caddyfile: Normalize & flatten all unmarshalers (#6037)
Diffstat (limited to 'caddyconfig/caddyfile')
-rw-r--r--caddyconfig/caddyfile/adapter.go32
1 files changed, 14 insertions, 18 deletions
diff --git a/caddyconfig/caddyfile/adapter.go b/caddyconfig/caddyfile/adapter.go
index d6ef602dc..edd825b88 100644
--- a/caddyconfig/caddyfile/adapter.go
+++ b/caddyconfig/caddyfile/adapter.go
@@ -92,30 +92,26 @@ func FormattingDifference(filename string, body []byte) (caddyconfig.Warning, bo
}, true
}
-// Unmarshaler is a type that can unmarshal
-// Caddyfile tokens to set itself up for a
-// JSON encoding. The goal of an unmarshaler
-// is not to set itself up for actual use,
-// but to set itself up for being marshaled
-// into JSON. Caddyfile-unmarshaled values
-// will not be used directly; they will be
-// encoded as JSON and then used from that.
-// Implementations must be able to support
-// multiple segments (instances of their
-// directive or batch of tokens); typically
-// this means wrapping all token logic in
-// a loop: `for d.Next() { ... }`.
+// Unmarshaler is a type that can unmarshal Caddyfile tokens to
+// set itself up for a JSON encoding. The goal of an unmarshaler
+// is not to set itself up for actual use, but to set itself up for
+// being marshaled into JSON. Caddyfile-unmarshaled values will not
+// be used directly; they will be encoded as JSON and then used from
+// that. Implementations _may_ be able to support multiple segments
+// (instances of their directive or batch of tokens); typically this
+// means wrapping parsing logic in a loop: `for d.Next() { ... }`.
+// More commonly, only a single segment is supported, so a simple
+// `d.Next()` at the start should be used to consume the module
+// identifier token (directive name, etc).
type Unmarshaler interface {
UnmarshalCaddyfile(d *Dispenser) error
}
// ServerType is a type that can evaluate a Caddyfile and set up a caddy config.
type ServerType interface {
- // Setup takes the server blocks which
- // contain tokens, as well as options
- // (e.g. CLI flags) and creates a Caddy
- // config, along with any warnings or
- // an error.
+ // Setup takes the server blocks which contain tokens,
+ // as well as options (e.g. CLI flags) and creates a
+ // Caddy config, along with any warnings or an error.
Setup([]ServerBlock, map[string]any) (*caddy.Config, []caddyconfig.Warning, error)
}