Versions in this module Expand all Collapse all v0 v0.0.1 Feb 6, 2025 Changes in this version + const EmailVerificationPurpose + const PasswordResetPurpose + var LogDir = flag.String("log-dir", "./logs", "specify the log directory") + var Port = flag.Int("port", 3000, "the listening port") + var PrintHelp = flag.Bool("help", false, "print help and exit") + var PrintVersion = flag.Bool("version", false, "print version and exit") + var RDB redis.Cmdable + var RedisEnabled = true + var SQLiteBusyTimeout = env.Int("SQLITE_BUSY_TIMEOUT", 3000) + var SQLitePath = "one-api.db" + var StartTime = time.Now().Unix() + var UsingMySQL = false + var UsingPostgreSQL = false + var UsingSQLite = false + var Validate *validator.Validate + var VerificationValidMinutes = 10 + var Version = "v0.0.0" + func DeleteKey(key string, purpose string) + func EmbedFolder(fsEmbed embed.FS, targetPath string) static.ServeFileSystem + func GenerateVerificationCode(length int) string + func GetRequestBody(c *gin.Context) ([]byte, error) + func Init() + func InitRedisClient() (err error) + func LogQuota(quota int64) string + func ParseRedisOption() *redis.Options + func Password2Hash(password string) (string, error) + func RedisDecrease(key string, value int64) error + func RedisDel(key string) error + func RedisGet(key string) (string, error) + func RedisSet(key string, value string, expiration time.Duration) error + func RegisterVerificationCodeWithKey(key string, code string, purpose string) + func SetEventStreamHeaders(c *gin.Context) + func UnmarshalBodyReusable(c *gin.Context, v any) error + func ValidatePasswordAndHash(password string, hash string) bool + func VerifyCodeWithKey(key string, code string, purpose string) bool + type CustomEvent struct + Data interface{} + Event string + Id string + Retry uint + func (r CustomEvent) Render(w http.ResponseWriter) error + func (r CustomEvent) WriteContentType(w http.ResponseWriter) + type InMemoryRateLimiter struct + func (l *InMemoryRateLimiter) Init(expirationDuration time.Duration) + func (l *InMemoryRateLimiter) Request(key string, maxRequestNum int, duration int64) bool