api/internal/config/handler_config.go
Peter Kurfer 9236a38be0 Moved endpoint handling to new module
- introduce new endpoints module
- introduce Endpoint and EndpointManager
- introduce new Logging abstraction API to allow proper mocking
- add error return value to Start and Shutdown of endpoints
- add mocks of some internals to allow easier testing
- add generate target to take care of all code generation
2020-04-14 00:15:33 +02:00

49 lines
976 B
Go

package config
import "github.com/spf13/viper"
const (
pluginConfigKey = "handler"
listenAddressConfigKey = "listenAddress"
portConfigKey = "port"
portsConfigKey = "ports"
)
type HandlerConfig interface {
HandlerName() string
ListenAddress() string
Port() uint16
Options() *viper.Viper
}
func NewHandlerConfig(handlerName string, port uint16, listenAddress string, options *viper.Viper) HandlerConfig {
return &handlerConfig{
handlerName: handlerName,
port: port,
listenAddress: listenAddress,
options: options,
}
}
type handlerConfig struct {
handlerName string
port uint16
listenAddress string
options *viper.Viper
}
func (h handlerConfig) HandlerName() string {
return h.handlerName
}
func (h handlerConfig) ListenAddress() string {
return h.listenAddress
}
func (h handlerConfig) Port() uint16 {
return h.port
}
func (h handlerConfig) Options() *viper.Viper {
return h.options
}