MCPcopy
hub / github.com/caddyserver/caddy / UnmarshalModule

Function UnmarshalModule

caddyconfig/caddyfile/adapter.go:127–142  ·  view source on GitHub ↗

UnmarshalModule instantiates a module with the given ID and invokes UnmarshalCaddyfile on the new value using the immediate next segment of d as input. In other words, d's next token should be the first token of the module's Caddyfile input. This function is used when the next segment of Caddyfile

(d *Dispenser, moduleID string)

Source from the content-addressed store, hash-verified

125// type-asserted to the module's associated type for practical use
126// when setting up a config.
127func UnmarshalModule(d *Dispenser, moduleID string) (Unmarshaler, error) {
128 mod, err := caddy.GetModule(moduleID)
129 if err != nil {
130 return nil, d.Errf("getting module named '%s': %v", moduleID, err)
131 }
132 inst := mod.New()
133 unm, ok := inst.(Unmarshaler)
134 if !ok {
135 return nil, d.Errf("module %s is not a Caddyfile unmarshaler; is %T", mod.ID, inst)
136 }
137 err = unm.UnmarshalCaddyfile(d.NewFromNextSegment())
138 if err != nil {
139 return nil, err
140 }
141 return unm, nil
142}
143
144// Interface guard
145var _ caddyconfig.Adapter = (*Adapter)(nil)

Callers 15

UnmarshalCaddyfileMethod · 0.92
unmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
UnmarshalCaddyfileMethod · 0.92
parseCaddyfileFunction · 0.92
loadFallbackPolicyFunction · 0.92

Calls 3

ErrfMethod · 0.80
NewFromNextSegmentMethod · 0.80
UnmarshalCaddyfileMethod · 0.65

Tested by

no test coverage detected