Allow specifying listen address

This commit is contained in:
Dominik George 2022-04-28 19:49:02 +02:00 committed by GitHub
parent 477643b58e
commit 47e562362b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -77,6 +77,7 @@ func main() {
viper.SetDefault("EMAIL_SUBJECT", "Thanks to try our product")
viper.SetDefault("DEMO_URL", "http://company.com/product-demo")
host := os.Getenv("HOST")
port := os.Getenv("PORT")
if port == "" {
port = "8080"
@ -90,5 +91,5 @@ func main() {
log.Printf("Listening on port %s", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
log.Fatal(http.ListenAndServe(host+":"+port, nil))
}