This commit is contained in:
2023-09-17 16:59:02 +08:00
parent 4f4a633035
commit 354379b12a
4 changed files with 24 additions and 13 deletions

View File

@ -14,6 +14,7 @@ type Config struct {
RequestMaxFileSize int64
CacheExpire int64
LogLevel string
BasePath string
}
var Default *Config
@ -27,6 +28,7 @@ func init() {
Port: 8011,
CacheExpire: 60 * 5,
LogLevel: "info",
BasePath: "/",
}
err := godotenv.Load()
if err != nil {
@ -69,4 +71,10 @@ func init() {
if os.Getenv("LOG_LEVEL") != "" {
Default.LogLevel = os.Getenv("LOG_LEVEL")
}
if os.Getenv("BASE_PATH") != "" {
Default.BasePath = os.Getenv("BASE_PATH")
if Default.BasePath[len(Default.BasePath)-1] != '/' {
Default.BasePath += "/"
}
}
}