Writing Config Adapters
If one does not already exist for the language/syntax/format you prefer, you can write one!
- See godoc for ‘Adapter’ interface
The returned JSON should not be indented; it should always be compact. The caller can always prettify it if they want to.
When populating fields of the config that are json.RawMessage
types (i.e. module fields), use the JSON()
and JSONModuleObject()
functions:
- is for marshaling module values without the module name embedded. (Often used for ModuleMap fields where the module name is the map key.)
Caddyfile Server Types
func init() {
caddyconfig.RegisterAdapter("caddyfile", caddyfile.Adapter{ServerType: ServerType{}})
You would implement the and register your own adapter accordingly.