From fb61bf1903aa6ce8cef75b2c240b7ce5b0956a34 Mon Sep 17 00:00:00 2001 From: bytedream Date: Mon, 31 Jan 2022 09:36:59 +0100 Subject: [PATCH] Set only server address --- .env | 3 +-- config/config.go | 8 +++----- main.go | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 7134d46..9e65f4a 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ ARTICLE_ROOT=./articles/ -SERVER_URL=localhost:8080 -SERVER_PORT=8080 +SERVER_ADDRESS=localhost:8080 PREFIX= diff --git a/config/config.go b/config/config.go index cfa09b4..eb00fa4 100644 --- a/config/config.go +++ b/config/config.go @@ -15,8 +15,7 @@ var PageBase pageBase var ( ArticleRoot string - ServerURL string - ServerPort string + ServerAddress string Prefix string @@ -29,8 +28,7 @@ func init() { ArticleRoot = os.Getenv("ARTICLE_ROOT") - ServerURL = os.Getenv("SERVER_URL") - ServerPort = os.Getenv("SERVER_PORT") + ServerAddress = os.Getenv("SERVER_ADDRESS") Prefix = os.Getenv("PREFIX") @@ -38,6 +36,6 @@ func init() { FrontendDir = os.Getenv("FRONTEND_DIR") PageBase = pageBase{ - BasePath: path.Join(ServerURL, Prefix), + BasePath: path.Join(ServerAddress, Prefix), } } diff --git a/main.go b/main.go index 84ad78b..8c3ef50 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func main() { } database.SetGlobDB(db) - if err := http.ListenAndServe(fmt.Sprintf("%s:%s", config.ServerURL, config.ServerPort), r); err != nil { + if err := http.ListenAndServe(fmt.Sprintf("%s:", config.ServerAddress), r); err != nil { panic(err) } }