aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/config/config.go10
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
}