Browse Source

Optimization, move code

Vova Tkach 5 years ago
parent
commit
572ac004f3
2 changed files with 28 additions and 36 deletions
  1. 28 0
      main.go
  2. 0 36
      params.go

+ 28 - 0
main.go

@@ -351,6 +351,34 @@ func main() {
 	)
 }
 
+func read_env_params() {
+	if consts.ParamHost == "0.0.0.0" {
+		if os.Getenv("FAVE_HOST") != "" {
+			consts.ParamHost = os.Getenv("FAVE_HOST")
+		}
+	}
+	if consts.ParamPort == 8080 {
+		if os.Getenv("FAVE_PORT") != "" {
+			consts.ParamPort = utils.StrToInt(os.Getenv("FAVE_PORT"))
+		}
+	}
+	if consts.ParamWwwDir == "" {
+		if os.Getenv("FAVE_DIR") != "" {
+			consts.ParamWwwDir = os.Getenv("FAVE_DIR")
+		}
+	}
+	if consts.ParamDebug == false {
+		if os.Getenv("FAVE_DEBUG") == "true" {
+			consts.ParamDebug = true
+		}
+	}
+	if consts.ParamKeepAlive == false {
+		if os.Getenv("FAVE_KEEPALIVE") == "true" {
+			consts.ParamKeepAlive = true
+		}
+	}
+}
+
 func ServeTemplateFile(
 	w http.ResponseWriter,
 	r *http.Request,

+ 0 - 36
params.go

@@ -1,36 +0,0 @@
-package main
-
-import (
-	"os"
-
-	"golang-fave/engine/consts"
-	"golang-fave/engine/utils"
-)
-
-func read_env_params() {
-	if consts.ParamHost == "0.0.0.0" {
-		if os.Getenv("FAVE_HOST") != "" {
-			consts.ParamHost = os.Getenv("FAVE_HOST")
-		}
-	}
-	if consts.ParamPort == 8080 {
-		if os.Getenv("FAVE_PORT") != "" {
-			consts.ParamPort = utils.StrToInt(os.Getenv("FAVE_PORT"))
-		}
-	}
-	if consts.ParamWwwDir == "" {
-		if os.Getenv("FAVE_DIR") != "" {
-			consts.ParamWwwDir = os.Getenv("FAVE_DIR")
-		}
-	}
-	if consts.ParamDebug == false {
-		if os.Getenv("FAVE_DEBUG") == "true" {
-			consts.ParamDebug = true
-		}
-	}
-	if consts.ParamKeepAlive == false {
-		if os.Getenv("FAVE_KEEPALIVE") == "true" {
-			consts.ParamKeepAlive = true
-		}
-	}
-}