diff --git a/main.go b/main.go index 865ef37..d90dbea 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,21 @@ import ( func main() { + host := os.Getenv("HOST") + if host == "" { + host = "0.0.0.0" + } + + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + + if os.Getenv("DEV") != "true" { + gin.SetMode(gin.ReleaseMode) + fmt.Printf("Running in production mode. Listening on %s:%s.", host, port) + } + r := gin.Default() r.LoadHTMLGlob("templates/*") @@ -32,15 +47,5 @@ func main() { r.GET("/questions/:id/:title", routes.ViewQuestion) - host := os.Getenv("HOST") - if host == "" { - host = "0.0.0.0" - } - - port := os.Getenv("PORT") - if port == "" { - port = "8080" - } - r.Run(fmt.Sprintf("%s:%s", host, port)) }