api/internal/endpoints/endpoint.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

31 lines
621 B
Go

//go:generate mockgen -source=endpoint.go -destination=./../../internal/mock/endpoints/endpoint_mock.go -package=endpoints_mock
package endpoints
import (
"github.com/baez90/inetmock/pkg/api"
"github.com/baez90/inetmock/pkg/config"
)
type Endpoint interface {
Start() error
Shutdown() error
Name() string
}
type endpoint struct {
name string
handler api.ProtocolHandler
config config.HandlerConfig
}
func (e endpoint) Name() string {
return e.name
}
func (e *endpoint) Start() (err error) {
return e.handler.Start(e.config)
}
func (e *endpoint) Shutdown() (err error) {
return e.handler.Shutdown()
}