return an error if no logOutput is provided

Otherwise the code will panic at a later stage where it is more complicated to figure out what’s actually going on.
This commit is contained in:
Felix 2016-09-17 17:46:13 +09:00
parent b2e867454a
commit f0eb0ba549
1 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,10 @@ type HTTPServer struct {
// NewHTTPServers starts new HTTP servers to provide an interface to // NewHTTPServers starts new HTTP servers to provide an interface to
// the agent. // the agent.
func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPServer, error) { func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPServer, error) {
if logOutput == nil {
return nil, fmt.Errorf("Please provide a valid logOutput(io.Writer)")
}
var servers []*HTTPServer var servers []*HTTPServer
if config.Ports.HTTPS > 0 { if config.Ports.HTTPS > 0 {