Allow setting port and log level in config
Change-Id: Ib9e4ac06292aeaad9154a9f11997ed3bd1ab6779
diff --git a/config/config.go b/config/config.go
index 46d6639..ff0db31 100644
--- a/config/config.go
+++ b/config/config.go
@@ -10,8 +10,10 @@
)
const (
- defaultServer = "https://korap.ids-mannheim.de/"
- defaultSDK = "https://korap.ids-mannheim.de/js/korap-plugin-latest.js"
+ defaultServer = "https://korap.ids-mannheim.de/"
+ defaultSDK = "https://korap.ids-mannheim.de/js/korap-plugin-latest.js"
+ defaultPort = 3000
+ defaultLogLevel = "warn"
)
// MappingRule represents a single mapping rule in the configuration
@@ -29,9 +31,11 @@
// MappingConfig represents the root configuration containing multiple mapping lists
type MappingConfig struct {
- SDK string `yaml:"sdk,omitempty"`
- Server string `yaml:"server,omitempty"`
- Lists []MappingList `yaml:"lists,omitempty"`
+ SDK string `yaml:"sdk,omitempty"`
+ Server string `yaml:"server,omitempty"`
+ Port int `yaml:"port,omitempty"`
+ LogLevel string `yaml:"loglevel,omitempty"`
+ Lists []MappingList `yaml:"lists,omitempty"`
}
// LoadFromSources loads configuration from multiple sources and merges them:
@@ -145,6 +149,12 @@
if config.Server == "" {
config.Server = defaultServer
}
+ if config.Port == 0 {
+ config.Port = defaultPort
+ }
+ if config.LogLevel == "" {
+ config.LogLevel = defaultLogLevel
+ }
}
// validateMappingLists validates a slice of mapping lists