global.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package global
  2. import (
  3. "github.com/gin-gonic/gin"
  4. ut "github.com/go-playground/universal-translator"
  5. "github.com/go-playground/validator/v10"
  6. "github.com/go-redis/redis/v8"
  7. "github.com/lejianwen/rustdesk-api/v2/config"
  8. "github.com/lejianwen/rustdesk-api/v2/lib/cache"
  9. "github.com/lejianwen/rustdesk-api/v2/lib/jwt"
  10. "github.com/lejianwen/rustdesk-api/v2/lib/lock"
  11. "github.com/lejianwen/rustdesk-api/v2/lib/upload"
  12. "github.com/lejianwen/rustdesk-api/v2/utils"
  13. "github.com/nicksnyder/go-i18n/v2/i18n"
  14. "github.com/sirupsen/logrus"
  15. "github.com/spf13/viper"
  16. "gorm.io/gorm"
  17. )
  18. var (
  19. DB *gorm.DB
  20. Logger *logrus.Logger
  21. ConfigPath string = ""
  22. Config config.Config
  23. Viper *viper.Viper
  24. Redis *redis.Client
  25. Cache cache.Handler
  26. Validator struct {
  27. Validate *validator.Validate
  28. UT *ut.UniversalTranslator
  29. VTrans ut.Translator
  30. ValidStruct func(*gin.Context, interface{}) []string
  31. ValidVar func(ctx *gin.Context, field interface{}, tag string) []string
  32. }
  33. Oss *upload.Oss
  34. Jwt *jwt.Jwt
  35. Lock lock.Locker
  36. Localizer func(lang string) *i18n.Localizer
  37. LoginLimiter *utils.LoginLimiter
  38. )