mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-13 09:24:02 +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
|
- ./config:/app/config
|
||||||
|
|
||||||
# if local docker provider is used
|
# 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
|
# use existing certificate
|
||||||
# - /path/to/cert.pem:/app/certs/cert.crt:ro
|
# - /path/to/cert.pem:/app/certs/cert.crt:ro
|
||||||
|
|
|
@ -24,10 +24,6 @@ type Config interface {
|
||||||
|
|
||||||
func NewConfig(path string) Config {
|
func NewConfig(path string) Config {
|
||||||
cfg := &config{
|
cfg := &config{
|
||||||
m: &configModel{
|
|
||||||
TimeoutShutdown: 3 * time.Second,
|
|
||||||
RedirectToHTTPS: false,
|
|
||||||
},
|
|
||||||
reader: &FileReader{Path: path},
|
reader: &FileReader{Path: path},
|
||||||
}
|
}
|
||||||
cfg.watcher = NewFileWatcher(
|
cfg.watcher = NewFileWatcher(
|
||||||
|
@ -60,7 +56,7 @@ func (cfg *config) Load(reader ...Reader) error {
|
||||||
return NewNestedError("unable to read config file").With(err)
|
return NewNestedError("unable to read config file").With(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
model := &configModel{}
|
model := defaultConfig()
|
||||||
if err := yaml.Unmarshal(data, model); err != nil {
|
if err := yaml.Unmarshal(data, model); err != nil {
|
||||||
return NewNestedError("unable to parse config file").With(err)
|
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"`
|
RedirectToHTTPS bool `yaml:"redirect_to_https" json:"redirect_to_https"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultConfig() *configModel {
|
||||||
|
return &configModel{
|
||||||
|
TimeoutShutdown: 3 * time.Second,
|
||||||
|
RedirectToHTTPS: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
m *configModel
|
m *configModel
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ func main() {
|
||||||
cfg = NewConfig(configPath)
|
cfg = NewConfig(configPath)
|
||||||
cfg.MustLoad()
|
cfg.MustLoad()
|
||||||
|
|
||||||
|
logrus.Info(cfg.Value())
|
||||||
|
|
||||||
if args.Command == CommandVerify {
|
if args.Command == CommandVerify {
|
||||||
logrus.Printf("config OK")
|
logrus.Printf("config OK")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue