mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fix default config value
This commit is contained in:
parent
77f957c7a8
commit
ca98b31458
4 changed files with 11 additions and 6 deletions
BIN
bin/go-proxy
BIN
bin/go-proxy
Binary file not shown.
|
@ -22,7 +22,7 @@ services:
|
|||
- ./config:/app/config
|
||||
|
||||
# if local docker provider is used
|
||||
# - /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
# use existing certificate
|
||||
# - /path/to/cert.pem:/app/certs/cert.crt:ro
|
||||
|
|
|
@ -24,10 +24,6 @@ type Config interface {
|
|||
|
||||
func NewConfig(path string) Config {
|
||||
cfg := &config{
|
||||
m: &configModel{
|
||||
TimeoutShutdown: 3 * time.Second,
|
||||
RedirectToHTTPS: false,
|
||||
},
|
||||
reader: &FileReader{Path: path},
|
||||
}
|
||||
cfg.watcher = NewFileWatcher(
|
||||
|
@ -60,7 +56,7 @@ func (cfg *config) Load(reader ...Reader) error {
|
|||
return NewNestedError("unable to read config file").With(err)
|
||||
}
|
||||
|
||||
model := &configModel{}
|
||||
model := defaultConfig()
|
||||
if err := yaml.Unmarshal(data, model); err != nil {
|
||||
return NewNestedError("unable to parse config file").With(err)
|
||||
}
|
||||
|
@ -188,6 +184,13 @@ type configModel struct {
|
|||
RedirectToHTTPS bool `yaml:"redirect_to_https" json:"redirect_to_https"`
|
||||
}
|
||||
|
||||
func defaultConfig() *configModel {
|
||||
return &configModel{
|
||||
TimeoutShutdown: 3 * time.Second,
|
||||
RedirectToHTTPS: false,
|
||||
}
|
||||
}
|
||||
|
||||
type config struct {
|
||||
m *configModel
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ func main() {
|
|||
cfg = NewConfig(configPath)
|
||||
cfg.MustLoad()
|
||||
|
||||
logrus.Info(cfg.Value())
|
||||
|
||||
if args.Command == CommandVerify {
|
||||
logrus.Printf("config OK")
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue