Enable the server to run without SSL if not certificate is provided

This commit is contained in:
Tarcisio Gruppi
2019-01-11 16:16:22 -02:00
parent 82757607f8
commit b1fdfcff37

View File

@@ -47,6 +47,10 @@ func main() {
log.Fatal(fmt.Errorf("failed to create api instance with: %s", err.Error()))
}
err = http.ListenAndServeTLS(":"+strconv.Itoa(config.Port), config.CertFile, config.KeyFile, app.MakeHandler())
if config.CertFile == "" || config.KeyFile == "" {
err = http.ListenAndServe(":"+strconv.Itoa(config.Port), app.MakeHandler())
} else {
err = http.ListenAndServeTLS(":"+strconv.Itoa(config.Port), config.CertFile, config.KeyFile, app.MakeHandler())
}
log.Fatal(fmt.Errorf("failed to start server with: %s", err.Error()))
}