2020-04-27 22:26:15 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2020-12-26 13:11:49 +00:00
|
|
|
type EndpointConfig struct {
|
2020-04-27 22:26:15 +00:00
|
|
|
Handler string
|
|
|
|
Ports []uint16
|
|
|
|
ListenAddress string
|
|
|
|
Options *viper.Viper
|
|
|
|
}
|
|
|
|
|
2020-12-26 13:11:49 +00:00
|
|
|
func (m EndpointConfig) HandlerConfigs() []HandlerConfig {
|
2020-04-27 22:26:15 +00:00
|
|
|
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
|
|
|
|
}
|