You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a decoder that will map config.Node's into Go types using reflection.
structures are unmarshalled using config.Map according to provided tags.
time.Duration is unmarshalled like config.Map.Duration
other types supported by config.Map are unmarshalled using the same way.
slices handle duplicates directives, each directive parsed as a separate entry.
config.StringSet
config.Node is copied as-is.
// Module config structure exampletypeConfigstruct{
Hostname`maddy:"hostname,required,inherit"`Timeout time.Duration`maddy:"timeout,required,inherit"`DataSize config.DataSize`maddy:"data_size"`// default without explicit value keeps existing valueDefaults config.DataSize`maddy:"default:1m"`DeliverTo []ModuleReference// multiple directivesAuthMethods config.Enum[string] `maddy:"enum:login plain oauth"`// one directive, duplicates fail, unknown values failIPs config.List[string] // one directive, duplicates allowed// unknown can be used multiple times Endpoint []GlobalEndpoint`maddy:"unknown"`SharedModules []GlobalModule`maddy:"unknown"`// Escape hatch for handling unknown directives via legacy code.// allows two-step processing.Unknown []config.Node`maddy:"unknown"`
}
typeConfigContextstruct{
*container.CGlobalsmap[string]any
}
// Sentinel error that can be returned by UnmarshalConfig when handling `unknown` struct field that tells// it to skip the directive and try parsing it varErrSkipUnknownerrortypeConfigUnmarshallerinterface{
UnmarshalConfig(*config.Node, ConfigContext) error
}
For referencing module instances that is lazily resolved.
Activity