mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-05 18:44:58 +03:00
core: Simplify Server initializer
This commit is contained in:
parent
3c36edec1f
commit
1a82943db2
2 changed files with 7 additions and 2 deletions
2
main.go
2
main.go
|
@ -63,7 +63,7 @@ func main() {
|
||||||
|
|
||||||
// Start each server with its one or more configurations
|
// Start each server with its one or more configurations
|
||||||
for addr, configs := range addresses {
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,12 @@ type Server struct {
|
||||||
// New creates a new Server which will bind to addr and serve
|
// New creates a new Server which will bind to addr and serve
|
||||||
// the sites/hosts configured in configs. This function does
|
// the sites/hosts configured in configs. This function does
|
||||||
// not start serving.
|
// 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{
|
s := &Server{
|
||||||
address: addr,
|
address: addr,
|
||||||
tls: tls,
|
tls: tls,
|
||||||
|
|
Loading…
Reference in a new issue