43 lines
697 B
Go
43 lines
697 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/joho/godotenv"
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
var (
|
|
ArticleRoot string
|
|
|
|
ServerAddress string
|
|
ServerPort string
|
|
Protocol string
|
|
|
|
Prefix 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"))
|
|
|
|
DatabaseFile = os.Getenv("DATABASE_FILE")
|
|
FrontendDir = os.Getenv("FRONTEND_DIR")
|
|
|
|
BasePath = Protocol + path.Join(fmt.Sprintf("%s:%s", ServerAddress, ServerPort), Prefix) + "/"
|
|
}
|