阶段性提交

This commit is contained in:
GoEdgeLab
2020-07-22 22:18:47 +08:00
parent cb5d9feb7a
commit ea05b2f236
19 changed files with 716 additions and 14 deletions

View File

@@ -0,0 +1,28 @@
package configs
import (
"github.com/go-yaml/yaml"
"github.com/iwind/TeaGo/Tea"
"io/ioutil"
)
type APIConfig struct {
RPC struct {
Endpoints []string `yaml:"endpoints"`
} `yaml:"rpc"`
}
func LoadAPIConfig() (*APIConfig, error) {
data, err := ioutil.ReadFile(Tea.ConfigFile("api.yaml"))
if err != nil {
return nil, err
}
config := &APIConfig{}
err = yaml.Unmarshal(data, config)
if err != nil {
return nil, err
}
return config, nil
}

View File

@@ -0,0 +1,11 @@
package configs
import "testing"
func TestLoadAPIConfig(t *testing.T) {
config, err := LoadAPIConfig()
if err != nil {
t.Fatal(err)
}
t.Log(config)
}

View File

@@ -0,0 +1,4 @@
package configs
type FilterConfig struct {
}

View File

@@ -4,6 +4,7 @@ type ServerConfig struct {
Id string `yaml:"id"` // ID
IsOn bool `yaml:"isOn"` // 是否开启
Components []*ComponentConfig `yaml:"components"` // 组件
Filters []*FilterConfig `yaml:"filters"` // 过滤器
Name string `yaml:"name"` // 名称
Description string `yaml:"description"` // 描述
ServerNames []string `yaml:"serverNames"` // 域名