gofiber-study/common/config/config.go

70 lines
1.8 KiB
Go
Raw Normal View History

package config
2022-10-25 01:58:30 +08:00
import (
"image/color"
)
type BasicConfig struct {
2022-10-25 01:58:30 +08:00
Server ServerConfig `yaml:"server"`
Mysql MysqlConfig `yaml:"mysql"`
Redis RedisConfig `yaml:"redis"`
Jwt JwtConfig `yaml:"jwt"`
NanoId NanoIdConfig `yaml:"nanoId"`
Captcha CaptchaConfig `yaml:"captcha"`
2022-10-06 20:46:17 +08:00
}
type NanoIdConfig struct {
Sequence string `yaml:"sequence"`
Length int `yaml:"length"`
}
type JwtConfig struct {
Secret string `yaml:"secret"`
Expire int64 `yaml:"expire"`
}
type MysqlConfig struct {
DataSources []string `yaml:"dataSources"`
AutoSync bool `yaml:"autoSync"`
}
type ServerConfig struct {
// 监听 地址:端口
Addr string `yaml:"addr"`
// 是否开启多进程
PreFork bool `yaml:"preFork"`
// 路由 大小写严格
CaseSensitive bool `yaml:"caseSensitive"`
// 严格路由 例: 设置为 true 时, /foo != /foo/
StrictRouting bool `yaml:"strictRouting"`
// 设置 Http 请求头中的 Server 名称
ServerHeader string `yaml:"serverHeader"`
// 是否添加 /routes 路由 用于获取所有路由信息
EnableRoutesMsg bool `yaml:"enableRoutesMsg"`
}
type RedisConfig struct {
Addr string `yaml:"addr"`
Pass string `yaml:"pass"`
2022-10-04 03:08:27 +08:00
DB int `yaml:"db"`
}
2022-10-25 01:58:30 +08:00
type CaptchaConfig struct {
Driver string `yaml:"driver"`
// Height png height in pixel.
Height int `yaml:"height"`
// Width Captcha png width in pixel.
Width int `yaml:"width"`
//NoiseCount text noise count.
NoiseCount int `yaml:"noiseCount"`
//ShowLineOptions := OptionShowHollowLine | OptionShowSlimeLine | OptionShowSineLine .
ShowLineOptions int `yaml:"showLineOptions"`
//Length random string length.
Length int `yaml:"length"`
//Source is a unicode which is the rand string from.
Source string `yaml:"source"`
//BgColor captcha image background color (optional)
BgColor *color.RGBA `yaml:"bgColor"`
}