Make a default config variable (#1848)
* Make a default config variable * decoder.Decode needs pointer to config
This commit is contained in:
@@ -264,9 +264,7 @@ func DefaultAPIConfig() APIConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []cli.Flag) (*Config, error) {
|
var DefaultConfig = Config{
|
||||||
// start with defaults
|
|
||||||
conf := &Config{
|
|
||||||
Port: 7880,
|
Port: 7880,
|
||||||
RTC: RTCConfig{
|
RTC: RTCConfig{
|
||||||
RTCConfig: rtcconfig.RTCConfig{
|
RTCConfig: rtcconfig.RTCConfig{
|
||||||
@@ -423,12 +421,15 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c
|
|||||||
StreamBufferSize: 1000,
|
StreamBufferSize: 1000,
|
||||||
},
|
},
|
||||||
Keys: map[string]string{},
|
Keys: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []cli.Flag) (*Config, error) {
|
||||||
|
// start with defaults
|
||||||
|
conf := DefaultConfig
|
||||||
if confString != "" {
|
if confString != "" {
|
||||||
decoder := yaml.NewDecoder(strings.NewReader(confString))
|
decoder := yaml.NewDecoder(strings.NewReader(confString))
|
||||||
decoder.KnownFields(strictMode)
|
decoder.KnownFields(strictMode)
|
||||||
if err := decoder.Decode(conf); err != nil {
|
if err := decoder.Decode(&conf); err != nil {
|
||||||
return nil, fmt.Errorf("could not parse config: %v", err)
|
return nil, fmt.Errorf("could not parse config: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,7 +474,7 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c
|
|||||||
conf.Environment = "dev"
|
conf.Environment = "dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
return conf, nil
|
return &conf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conf *Config) IsTURNSEnabled() bool {
|
func (conf *Config) IsTURNSEnabled() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user