From 9be3251875d7464700d6902b759a5001b1cd3d54 Mon Sep 17 00:00:00 2001 From: fengqi Date: Thu, 29 Sep 2022 15:18:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=87=AA=E5=AE=9A=E4=B9=89pa?= =?UTF-8?q?rse=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/remote/async.go | 7 ++++++- component/remote/sync.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/component/remote/async.go b/component/remote/async.go index 623e696..2fb8512 100644 --- a/component/remote/async.go +++ b/component/remote/async.go @@ -175,7 +175,12 @@ func createApolloConfigWithJSON(b []byte, callback http.CallBack) (o interface{} if parser == nil { return apolloConfig, nil } - m, err := parser.Parse(apolloConfig.Configurations[defaultContentKey]) + + content, ok := apolloConfig.Configurations[defaultContentKey] + if !ok { + content = string(b) + } + m, err := parser.Parse(content) if err != nil { log.Debugf("GetContent fail ! error: %v", err) } diff --git a/component/remote/sync.go b/component/remote/sync.go index 8153587..ea51487 100644 --- a/component/remote/sync.go +++ b/component/remote/sync.go @@ -83,7 +83,12 @@ func processJSONFiles(b []byte, callback http.CallBack) (o interface{}, err erro if parser == nil { return apolloConfig, nil } - m, err := parser.Parse(configurations[defaultContentKey]) + + content, ok := configurations[defaultContentKey] + if !ok { + content = string(b) + } + m, err := parser.Parse(content) if err != nil { log.Debugf("GetContent fail ! error: %v", err) }