This commit is contained in:
2023-09-27 14:54:53 +08:00
parent 6f075ea44e
commit edfd70a77d
4 changed files with 14 additions and 12 deletions

View File

@ -15,8 +15,8 @@ type Config struct {
RequestMaxFileSize int64
CacheExpire int64
LogLevel string
BasePath string
ShortLinkLength int
//BasePath string
ShortLinkLength int
}
var Default *Config
@ -32,8 +32,8 @@ func LoadConfig() error {
Port: 8011,
CacheExpire: 60 * 5,
LogLevel: "info",
BasePath: "/",
ShortLinkLength: 6,
//BasePath: "/",
ShortLinkLength: 6,
}
_ = godotenv.Load()
if os.Getenv("PORT") != "" {
@ -73,12 +73,12 @@ func LoadConfig() error {
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 += "/"
}
}
//if os.Getenv("BASE_PATH") != "" {
// Default.BasePath = os.Getenv("BASE_PATH")
// if Default.BasePath[len(Default.BasePath)-1] != '/' {
// Default.BasePath += "/"
// }
//}
if os.Getenv("SHORT_LINK_LENGTH") != "" {
atoi, err := strconv.Atoi(os.Getenv("SHORT_LINK_LENGTH"))
if err != nil {