分享码有效期,支持表达式

This commit is contained in:
eafonyang
2026-06-15 20:02:43 +08:00
parent fc4ec2c030
commit b5560ca702
9 changed files with 130 additions and 9 deletions
+8 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strconv"
"time"
)
type Config struct {
@@ -17,7 +18,7 @@ type Config struct {
S3 S3Config
EnablePersistTask bool
ShareCodeMaxPerMac int
ShareCodeTTLMin int
ShareCodeTTL time.Duration
}
func Load() (*Config, error) {
@@ -49,6 +50,11 @@ func Load() (*Config, error) {
eq := loadEqualize(env)
s3cfg := loadS3(env)
shareCodeTTL, err := parseShareCodeTTL(getEnv("SHARE_CODE_TTL_MIN", "30"))
if err != nil {
return nil, fmt.Errorf("invalid SHARE_CODE_TTL_MIN: %w", err)
}
return &Config{
Env: env,
Host: getEnv("APP_HOST", "0.0.0.0"),
@@ -60,7 +66,7 @@ func Load() (*Config, error) {
S3: s3cfg,
EnablePersistTask: getEnv("ENABLE_PERSIST_TASK", "false") == "true",
ShareCodeMaxPerMac: getEnvInt("SHARE_CODE_MAX_PER_MAC", 1),
ShareCodeTTLMin: getEnvInt("SHARE_CODE_TTL_MIN", 30),
ShareCodeTTL: shareCodeTTL,
}, nil
}