aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddyconfig/configadapters.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-08-22 14:52:39 -0600
committerMatthew Holt <[email protected]>2019-08-22 14:52:39 -0600
commitafd154119a24786be44996990028d177569f4a58 (patch)
treef3ef4899af6b684676f2969ebd91bbff2633c919 /caddyconfig/configadapters.go
parente34ff21a7183969afb4150f1f7a1f71b9a1dd0d6 (diff)
downloadcaddy-afd154119a24786be44996990028d177569f4a58.tar.gz
caddy-afd154119a24786be44996990028d177569f4a58.zip
admin: Support config adapters at /load endpoint
Based on Content-Type
Diffstat (limited to 'caddyconfig/configadapters.go')
-rw-r--r--caddyconfig/configadapters.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/caddyconfig/configadapters.go b/caddyconfig/configadapters.go
index c5391766c..1a0801fb5 100644
--- a/caddyconfig/configadapters.go
+++ b/caddyconfig/configadapters.go
@@ -98,6 +98,8 @@ func JSONIndent(val interface{}) ([]byte, error) {
return json.MarshalIndent(val, "", "\t")
}
+// RegisterAdapter registers a config adapter with the given name.
+// This should usually be done at init-time.
func RegisterAdapter(name string, adapter Adapter) error {
if _, ok := configAdapters[name]; ok {
return fmt.Errorf("%s: already registered", name)
@@ -106,6 +108,8 @@ func RegisterAdapter(name string, adapter Adapter) error {
return nil
}
+// GetAdapter returns the adapter with the given name,
+// or nil if one with that name is not registered.
func GetAdapter(name string) Adapter {
return configAdapters[name]
}