api/pkg/config/multi_handler_config.go
Peter Kurfer 91f0cf6963 Improve config and startup handling
- use `Unmarshal` method of viper
- move config loading, defaulting and stuff to config package
- move serve to an extra command and move keep only global flags in root command
- add startup logic to onInit method in root command
- update mocks
- clean config structs
- adopt changes in plugins
- update default config
2020-06-15 12:32:18 +02:00

25 lines
504 B
Go

package config
import (
"github.com/spf13/viper"
)
type MultiHandlerConfig struct {
Handler string
Ports []uint16
ListenAddress string
Options *viper.Viper
}
func (m MultiHandlerConfig) HandlerConfigs() []HandlerConfig {
configs := make([]HandlerConfig, 0)
for _, port := range m.Ports {
configs = append(configs, HandlerConfig{
HandlerName: m.Handler,
Port: port,
ListenAddress: m.ListenAddress,
Options: m.Options,
})
}
return configs
}