做完了一部分,备份一下,防止以外删除
This commit is contained in:
21
pkg/constants/constants.go
Normal file
21
pkg/constants/constants.go
Normal 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
13
pkg/constants/redis.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user