Fixed base path (again again again) and rewrote .env

This commit is contained in:
2022-02-02 10:28:26 +01:00
parent 83931bd2a4
commit a189b7a378
9 changed files with 19 additions and 35 deletions

View File

@@ -1,42 +1,27 @@
package config
import (
"fmt"
"github.com/joho/godotenv"
"os"
"path"
)
var (
ArticleRoot string
ServerPort string
ServerAddress string
ServerPort string
Protocol string
Prefix string
Address string
Path string
DatabaseFile string
FrontendDir string
// not specified in config
BasePath string
)
func init() {
godotenv.Load()
ArticleRoot = os.Getenv("ARTICLE_ROOT")
ServerAddress = os.Getenv("SERVER_ADDRESS")
ServerPort = os.Getenv("SERVER_PORT")
Protocol = os.Getenv("PROTOCOL")
Prefix = path.Join(os.Getenv("PREFIX"))
Address = os.Getenv("ADDRESS")
DatabaseFile = os.Getenv("DATABASE_FILE")
FrontendDir = os.Getenv("FRONTEND_DIR")
BasePath = Protocol + "://" + path.Join(fmt.Sprintf("%s:%s", ServerAddress, ServerPort), Prefix) + "/"
}