diff --git a/admin/config/extend.go b/admin/config/extend.go index 2a7a9be..e78c286 100644 --- a/admin/config/extend.go +++ b/admin/config/extend.go @@ -10,14 +10,14 @@ var ExtConfig Extend // // 使用方法: config.ExtConfig......即可!! type Extend struct { - AMap AMap `yaml:"amap"` - Chorus Chorus `yaml:"chorus"` + AMap AMap `json:"amap" yaml:"amap"` + Chorus Chorus `json:"chorus" yaml:"chorus"` } type AMap struct { - Key string `yaml:"key"` + Key string `json:"key" yaml:"key"` } type Chorus struct { - StorageRoot string `yaml:"storage_root"` + StorageRoot string `json:"storage_root" yaml:"storage_root"` } diff --git a/admin/config/extend_test.go b/admin/config/extend_test.go new file mode 100644 index 0000000..b395de9 --- /dev/null +++ b/admin/config/extend_test.go @@ -0,0 +1,16 @@ +package config + +import ( + "encoding/json" + "testing" +) + +func TestExtendDecodesStorageRootFromGoAdminJSONReader(t *testing.T) { + var config Extend + if err := json.Unmarshal([]byte(`{"chorus":{"storage_root":"../var/storage"}}`), &config); err != nil { + t.Fatal(err) + } + if config.Chorus.StorageRoot != "../var/storage" { + t.Fatalf("storage root = %q", config.Chorus.StorageRoot) + } +} diff --git a/admin/config/settings.example.yml b/admin/config/settings.example.yml index 799739d..44f6a32 100644 --- a/admin/config/settings.example.yml +++ b/admin/config/settings.example.yml @@ -24,4 +24,4 @@ settings: extend: chorus: # Read-only access to the same protected storage root used by Portal. - storage_root: ../var/storage + storage_root: ../var/storage