diff --git a/main.go b/main.go index 38c7d6bc..498a5eab 100644 --- a/main.go +++ b/main.go @@ -63,7 +63,7 @@ func main() { // Start each server with its one or more configurations for addr, configs := range addresses { - s, err := server.New(addr.String(), configs, configs[0].TLS.Enabled) + s, err := server.New(addr.String(), configs) if err != nil { log.Fatal(err) } diff --git a/server/server.go b/server/server.go index 4a751de6..ad15ac31 100644 --- a/server/server.go +++ b/server/server.go @@ -29,7 +29,12 @@ type Server struct { // New creates a new Server which will bind to addr and serve // the sites/hosts configured in configs. This function does // not start serving. -func New(addr string, configs []Config, tls bool) (*Server, error) { +func New(addr string, configs []Config) (*Server, error) { + var tls bool + if len(configs) > 0 { + tls = configs[0].TLS.Enabled + } + s := &Server{ address: addr, tls: tls,