mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
优化API配置格式化
This commit is contained in:
@@ -17,9 +17,9 @@ type APIConfig struct {
|
|||||||
OldRPC struct {
|
OldRPC struct {
|
||||||
Endpoints []string `yaml:"endpoints"`
|
Endpoints []string `yaml:"endpoints"`
|
||||||
DisableUpdate bool `yaml:"disableUpdate"`
|
DisableUpdate bool `yaml:"disableUpdate"`
|
||||||
} `yaml:"rpc"`
|
} `yaml:"rpc,omitempty"`
|
||||||
|
|
||||||
RPCEndpoints []string `yaml:"rpc.endpoints" json:"rpc.endpoints"`
|
RPCEndpoints []string `yaml:"rpc.endpoints,flow" json:"rpc.endpoints"`
|
||||||
RPCDisableUpdate bool `yaml:"rpc.disableUpdate" json:"rpc.disableUpdate"`
|
RPCDisableUpdate bool `yaml:"rpc.disableUpdate" json:"rpc.disableUpdate"`
|
||||||
|
|
||||||
NodeId string `yaml:"nodeId"`
|
NodeId string `yaml:"nodeId"`
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package configs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/iwind/TeaGo/bootstrap"
|
_ "github.com/iwind/TeaGo/bootstrap"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,10 +12,16 @@ func TestLoadAPIConfig(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log(config)
|
t.Log(config)
|
||||||
|
|
||||||
|
configData, err := yaml.Marshal(config)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(string(configData))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIConfig_WriteFile(t *testing.T) {
|
func TestAPIConfig_WriteFile(t *testing.T) {
|
||||||
config := &APIConfig{}
|
var config = &APIConfig{}
|
||||||
err := config.WriteFile("/tmp/api_config.yaml")
|
err := config.WriteFile("/tmp/api_config.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user