Support listening for SSL connections
This commit is contained in:
parent
2db705f697
commit
aa710ec9d6
12
wings.go
12
wings.go
|
@ -91,11 +91,19 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
router := r.ConfigureRouter()
|
router := r.ConfigureRouter()
|
||||||
zap.S().Infow("configuring webserver", zap.String("host", c.Api.Host), zap.Int("port", c.Api.Port))
|
zap.S().Infow("configuring webserver", zap.Bool("ssl", c.Api.Ssl.Enabled), zap.String("host", c.Api.Host), zap.Int("port", c.Api.Port))
|
||||||
if err := http.ListenAndServe(fmt.Sprintf("%s:%d", c.Api.Host, c.Api.Port), router); err != nil {
|
|
||||||
|
addr := fmt.Sprintf("%s:%d", c.Api.Host, c.Api.Port)
|
||||||
|
if c.Api.Ssl.Enabled {
|
||||||
|
if err := http.ListenAndServeTLS(addr, c.Api.Ssl.CertificateFile, c.Api.Ssl.KeyFile, router); err != nil {
|
||||||
|
zap.S().Fatalw("failed to configure HTTPS server", zap.Error(err))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := http.ListenAndServe(addr, router); err != nil {
|
||||||
zap.S().Fatalw("failed to configure HTTP server", zap.Error(err))
|
zap.S().Fatalw("failed to configure HTTP server", zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Configures the global logger for Zap so that we can call it from any location
|
// Configures the global logger for Zap so that we can call it from any location
|
||||||
// in the code without having to pass around a logger instance.
|
// in the code without having to pass around a logger instance.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user