Documentation
¶
Index ¶
- func Assert(condition bool, msg string, code ...int)
- func AssertErr(err error, msg string, code ...int)
- func CheckDateDuring(start, end int64)
- func CheckReward(reward, rewardObject string, rewardValue float32)
- func GetFileHash(file multipart.File) (string, error)
- func GetHash(data string) string
- func GetRandomString(l int) string
- func IsEmail(email string) bool
- func IsGender(gender string) bool
- func IsTaskStatus(status string) bool
- func IsUserType(userType string) bool
- func JSON(ctx context.Context, v interface{})
- func NewErrorHandler() context.Handler
- type COSConfig
- type Config
- type DBConfig
- type EmailConfig
- type ErrorRes
- type HTTPConfig
- type RedisConfig
- type SessionConfig
- type VioletConfig
- type WechatConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErr ¶
AssertErr 错误断言 当 error 不为 nil 时触发 panic 对于当前请求不会再执行接下来的代码,并且返回指定格式的错误信息和错误码 若 msg 为空,则默认为 error 中的内容
func CheckReward ¶
CheckReward 判断是否为合法酬劳
Types ¶
type COSConfig ¶
type COSConfig struct {
AppID string `yaml:"id"`
AppSecret string `yaml:"secret"`
URL string `yaml:"url"`
}
COSConfig 腾讯云 对象存储配置
type Config ¶
type Config struct {
Dev bool `yaml:"dev"` // 开发模式
HTTP HTTPConfig `yaml:"http"` // HTTP 配置
Db DBConfig `yaml:"db"` // 数据库配置
Redis RedisConfig `yaml:"redis"` // Redis 配置
Violet VioletConfig `yaml:"violet"` // Violet 配置
Wechat WechatConfig `yaml:"wechat"` // 微信小程序 配置
COS COSConfig `yaml:"cos"`
Email EmailConfig `yaml:"email"`
}
Config 应用配置
type DBConfig ¶
type DBConfig struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
DBName string `yaml:"db"`
User string `yaml:"user"`
Password string `yaml:"password"`
}
DBConfig 数据库配置
type EmailConfig ¶
type EmailConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
From string `yaml:"from"`
}
EmailConfig 邮件服务配置
type HTTPConfig ¶
type HTTPConfig struct {
Host string `yaml:"host"` // 监听地址
Port string `yaml:"port"` // 监听端口
Session SessionConfig `yaml:"session"` // Session 配置
}
HTTPConfig 服务器配置
type RedisConfig ¶
type RedisConfig struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
Password string `yaml:"password"`
DB int `yaml:"db"`
Session string `yaml:"session"`
}
RedisConfig 缓存配置
type SessionConfig ¶
type SessionConfig struct {
Key string `yaml:"key"` // Cookies 名字
Expires int `yaml:"expires"` // 过期天数
}
SessionConfig Session 配置
type VioletConfig ¶
type VioletConfig struct {
ClientID string `yaml:"id"`
ClientKey string `yaml:"key"`
ServerHost string `yaml:"host"`
Callback string `yaml:"callback"`
}
VioletConfig Violet 配置
type WechatConfig ¶
WechatConfig 微信小程序配置
Click to show internal directories.
Click to hide internal directories.