summaryrefslogtreecommitdiff
path: root/caddy.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-12-12 14:30:22 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-12-12 14:30:22 -0700
commitf935458e3e30a8d9f47f37ad35fe9c546b841fa3 (patch)
tree25c2e6365d8f1934bd9cb5b9e8faeee0b8a2ce3f /caddy.go
parent2e0615270d157beb293bfce832a8a39bc6f2e749 (diff)
cmd: Fix validate command when JSON contains "@id" fields
Also, don't run admin server when validating...
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/caddy.go b/caddy.go
index 9dcd883..f13540d 100644
--- a/caddy.go
+++ b/caddy.go
@@ -153,16 +153,7 @@ func changeConfig(method, path string, input []byte, forceReload bool) error {
// (an alternate way to do this would be to delete them from
// rawCfg as they are indexed, then iterate the index we made
// and add them back after encoding as JSON)
- newCfg = idRegexp.ReplaceAllFunc(newCfg, func(in []byte) []byte {
- // matches with a comma on both sides (when "@id" property is
- // not the first or last in the object) need to keep exactly
- // one comma for correct JSON syntax
- comma := []byte{','}
- if bytes.HasPrefix(in, comma) && bytes.HasSuffix(in, comma) {
- return comma
- }
- return []byte{}
- })
+ newCfg = RemoveMetaFields(newCfg)
// load this new config; if it fails, we need to revert to
// our old representation of caddy's actual config
@@ -295,9 +286,11 @@ func run(newCfg *Config, start bool) error {
var err error
// start the admin endpoint (and stop any prior one)
- err = replaceAdmin(newCfg)
- if err != nil {
- return fmt.Errorf("starting caddy administration endpoint: %v", err)
+ if start {
+ err = replaceAdmin(newCfg)
+ if err != nil {
+ return fmt.Errorf("starting caddy administration endpoint: %v", err)
+ }
}
if newCfg == nil {