update config to file
This commit is contained in:
14
structure.go
14
structure.go
@@ -8,6 +8,9 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Address string `yaml:"address"`
|
||||
DBType string `yaml:"dbtype"`
|
||||
DBAddr string `yaml:"dbaddr"`
|
||||
Authorization string `yaml:"authorization"`
|
||||
Upstreams []OPENAI_UPSTREAM `yaml:"upstreams"`
|
||||
}
|
||||
@@ -32,5 +35,16 @@ func readConfig(filepath string) Config {
|
||||
log.Fatalf("Error unmarshaling YAML: %s", err)
|
||||
}
|
||||
|
||||
// set default value
|
||||
if config.Address == "" {
|
||||
config.Address = ":8888"
|
||||
}
|
||||
if config.DBType == "" {
|
||||
config.DBType = "sqlite"
|
||||
}
|
||||
if config.DBAddr == "" {
|
||||
config.DBAddr = "./db.sqlite"
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user