Added Config.Address to allow the server to bind to a different IP address

This commit is contained in:
Tarcisio Gruppi
2019-01-11 16:16:56 -02:00
parent b1fdfcff37
commit 0f8d2d65d8
3 changed files with 4 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package types
type Config struct {
WebUrl string
Address string
Port int
ApiPrefix string
KeyFile string

View File

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