From 92c5e1e4d073c82e12e26170379cb5c8d90ab2e8 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 6 Apr 2021 16:46:05 +0200 Subject: Added trainStop config parameter which was wrongly hardcoded --- pkg/config/config.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pkg/config/config.go') 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 } -- cgit v1.2.3