Fixed base path (again again again) and rewrote .env
This commit is contained in:
@@ -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) + "/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user