做完了一部分,备份一下,防止以外删除

This commit is contained in:
2025-11-11 15:16:38 +08:00
parent 9600e5b6e0
commit e98dd4d725
39 changed files with 2423 additions and 183 deletions

View File

@@ -0,0 +1,21 @@
package constants
// Fiber Locals 的上下文键
const (
ContextKeyRequestID = "requestid"
ContextKeyUserID = "user_id"
ContextKeyStartTime = "start_time"
)
// 配置环境变量
const (
EnvConfigPath = "CONFIG_PATH"
EnvConfigEnv = "CONFIG_ENV" // dev, staging, prod
)
// 默认配置值
const (
DefaultConfigPath = "configs/config.yaml"
DefaultServerAddr = ":3000"
DefaultRedisAddr = "localhost:6379"
)

13
pkg/constants/redis.go Normal file
View File

@@ -0,0 +1,13 @@
package constants
import "fmt"
// RedisAuthTokenKey 生成认证令牌的 Redis 键
func RedisAuthTokenKey(token string) string {
return fmt.Sprintf("auth:token:%s", token)
}
// RedisRateLimitKey 生成限流的 Redis 键
func RedisRateLimitKey(ip string) string {
return fmt.Sprintf("ratelimit:%s", ip)
}