feat 初次提交
This commit is contained in:
39
config/config.go
Normal file
39
config/config.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package config
|
||||
|
||||
import "common/config"
|
||||
|
||||
const (
|
||||
path = "./config"
|
||||
KeyUserAccessToken = "user:access:%v"
|
||||
KeyUserRefreshToken = "user:refresh:%v"
|
||||
)
|
||||
|
||||
// PublicPaths 不需要鉴权的接口,硬编码注册
|
||||
var PublicPaths = []string{
|
||||
"/user/info",
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
App *config.AppConfig `yaml:"app"`
|
||||
Log *config.LogConfig `yaml:"log"`
|
||||
Metric *config.MetricConfig `yaml:"metric"`
|
||||
DB *config.DBConfig `yaml:"db"`
|
||||
Serve *config.ServeConfig `yaml:"serve"`
|
||||
Auth *struct {
|
||||
Secret string `yaml:"secret"`
|
||||
Expire int64 `yaml:"expire"`
|
||||
}
|
||||
}
|
||||
|
||||
var cfg *Config
|
||||
|
||||
// LoadConfig 加载应用配置
|
||||
func LoadConfig() error {
|
||||
c, err := config.LoadConfig(path, cfg)
|
||||
cfg = c
|
||||
return err
|
||||
}
|
||||
|
||||
func Get() *Config {
|
||||
return cfg
|
||||
}
|
||||
Reference in New Issue
Block a user