diff options
author | Julien Dessaux | 2021-04-06 16:46:05 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-04-06 16:46:05 +0200 |
commit | 92c5e1e4d073c82e12e26170379cb5c8d90ab2e8 (patch) | |
tree | d862f6ea5a3f22c6c8ad268c7ddf5bb2536fa95c /pkg/config/config.go | |
parent | Added a flag to specify a configuration file and wrote a proper readme (diff) | |
download | trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.gz trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.bz2 trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.zip |
Added trainStop config parameter which was wrongly hardcoded
Diffstat (limited to '')
-rw-r--r-- | pkg/config/config.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index f97467a..6e4bba5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -9,13 +9,17 @@ import ( ) var validToken = regexp.MustCompile(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`) +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"` - Port string `yaml:"port",default:"8080"` + // Port is the tcp port number or service name the web server will listen to + Port string `yaml:"port",default:"8080"` // Token is the sncf api token Token string `yaml:"token"` + // TrainStop is the navitia code of the train stop the webapp will monitor + TrainStop string `yaml:"trainStop"` } func (c *Config) validate() error { @@ -33,6 +37,10 @@ func (c *Config) validate() error { if ok := validToken.MatchString(c.Token); !ok { return newInvalidTokenError(c.Token) } + // TrainStop + if ok := validTrainStop.MatchString(c.TrainStop); !ok { + return newInvalidTrainStopError(c.TrainStop) + } return nil } |