aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 6e4bba5..795ccd0 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -13,9 +13,9 @@ var validTrainStop = regexp.MustCompile(`^[a-zA-Z0-9:_]+$`)
type Config struct {
// Address is the hostname or ip the web server will listen to
- Address string `yaml:"address",default:"127.0.0.1"`
+ Address string `yaml:"address"`
// Port is the tcp port number or service name the web server will listen to
- Port string `yaml:"port",default:"8080"`
+ Port string `yaml:"port"`
// Token is the sncf api token
Token string `yaml:"token"`
// TrainStop is the navitia code of the train stop the webapp will monitor
@@ -24,12 +24,18 @@ type Config struct {
func (c *Config) validate() error {
// address
+ if c.Address == "" {
+ c.Address = "127.0.0.1"
+ }
if ip := net.ParseIP(c.Address); ip == nil {
if _, err := net.LookupIP(c.Address); err != nil {
return newInvalidAddressError(c.Address, err)
}
}
// port
+ if c.Port == "" {
+ c.Port = "8080"
+ }
if _, err := net.LookupPort("tcp", c.Port); err != nil {
return newInvalidPortError(c.Port, err)
}