feat: distinguish host and serve port

This commit is contained in:
Teajey 2024-05-20 22:59:54 +12:00
parent d000f23fba
commit 60831449de
Signed by: Teajey
GPG Key ID: 970E790FE834A713
3 changed files with 5 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
.DS_Store .DS_Store
gin-bin gin-bin
lishwist.db lishwist.db
.env .env*.local
db/init_sql.go db/init_sql.go

5
env/env.go vendored
View File

@ -15,8 +15,9 @@ func GuaranteeEnv(key string) (variable string) {
} }
var JwtSecret = GuaranteeEnv("LISHWIST_JWT_SECRET") var JwtSecret = GuaranteeEnv("LISHWIST_JWT_SECRET")
var HostDomain = GuaranteeEnv("LISHWIST_DOMAIN") var HostDomain = GuaranteeEnv("LISHWIST_HOST_DOMAIN")
var HostPort = os.Getenv("LISHWIST_PORT") var HostPort = os.Getenv("LISHWIST_HOST_PORT")
var ServePort = GuaranteeEnv("LISHWIST_SERVE_PORT")
var HostUrl = func() *url.URL { var HostUrl = func() *url.URL {
rawUrl := "http://" + HostDomain rawUrl := "http://" + HostDomain
if HostPort != "" { if HostPort != "" {

View File

@ -45,5 +45,5 @@ func main() {
http.Handle("/", authMiddleware) http.Handle("/", authMiddleware)
http.ListenAndServe(":"+env.HostPort, nil) http.ListenAndServe(":"+env.ServePort, nil)
} }