feat: production mode
This commit is contained in:
parent
504144c94b
commit
26c7a5f5ee
25
main.go
25
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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user