config

package
v0.0.0-...-e5d1c0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProjectName 项目名称
	ProjectName = "fangfang-api"

	// ProjectVersion 项目版本
	ProjectVersion = "v1.0.1"

	// ProjectAccessLogFile 项目访问日志存放文件
	ProjectAccessLogFile = "./logs/" + ProjectName + "-access.log"

	// ProjectCronLogFile 项目后台任务日志存放文件
	ProjectCronLogFile = "./logs/" + ProjectName + "-cron.log"

	// HeaderLoginToken 登录验证 Token,Header 中传递的参数
	HeaderLoginToken = "Token"

	// HeaderSignToken 签名验证 Authorization,Header 中传递的参数
	HeaderSignToken = "Authorization"

	// HeaderSignTokenDate 签名验证 Date,Header 中传递的参数
	HeaderSignTokenDate = "Authorization-Date"

	// HeaderSignTokenTimeout 签名有效期为 5 分钟
	HeaderSignTokenTimeout = time.Minute * 5

	// RedisKeyPrefixLoginUser Redis Key 前缀 - 登录用户信息
	RedisKeyPrefixLoginUser = ProjectName + ":login-user:"

	// RedisKeyPrefixUser Redis Key 前缀 - 用户路由
	RedisKeyPrefixUserMenu = ProjectName + ":user-menu:"

	// RedisKeyPrefixSignature Redis Key 前缀 - 签名验证信息
	RedisKeyPrefixSignature = ProjectName + ":signature:"

	// RedisKeySysData Redis Key 前缀 - 缓存数据信息
	RedisKeySysData = ProjectName + ":SysData:"

	// RedisKeySysTable Redis Key 前缀 - 缓存table配置
	RedisKeySysTable = ProjectName + ":SysTable:"

	// RedisKeySysTable Redis Key 前缀 - 缓存table配置
	RedisKeySysColumn = ProjectName + ":SysColumn:"

	// RedisKeySysTable Redis Key 前缀 - 缓存table配置
	RedisKeySysDict = ProjectName + ":SysDict:"

	// MaxRequestsPerSecond 每秒最大请求量
	MaxRequestsPerSecond = 10000

	// LoginSessionTTL 登录有效期为 24 小时
	LoginSessionTTL = time.Hour * 24

	//RedisCapchaKey 验证码缓存
	RedisCaptchaKey = ProjectName + ":Captcha:"

	// ZhCN 简体中文 - 中国
	ZhCN = "zh-cn"

	// EnUS 英文 - 美国
	EnUS = "en-us"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	MaxOpenConn     int           `mapstructure:"maxOpenConn" json:"maxOpenConn" yaml:"maxOpenConn"`             //连接池
	MaxIdleConn     int           `mapstructure:"maxIdleConn" json:"maxIdleConn" yaml:"maxIdleConn"`             //最大连接数
	ConnMaxLifeTime time.Duration `mapstructure:"connMaxLifeTime" json:"connMaxLifeTime" yaml:"connMaxLifeTime"` //链接超时时间
}

type Captcha

type Captcha struct {
	KeyLong   int `mapstructure:"key-long" json:"key-long" yaml:"key-long"`       // 验证码长度
	ImgWidth  int `mapstructure:"img-width" json:"img-width" yaml:"img-width"`    // 验证码宽度
	ImgHeight int `mapstructure:"img-height" json:"img-height" yaml:"img-height"` // 验证码高度
}

type Config

type Config struct {
	Redis    Redis    `mapstructure:"redis" json:"redis" yaml:"redis"`          //redis配置文件
	Mysql    Mysql    `mapstructure:"mysql" json:"mysql" yaml:"mysql"`          //mysql配置
	System   System   `mapstructure:"system" json:"system" yaml:"system"`       //系统配置
	Language Language `mapstructure:"language" json:"language" yaml:"language"` //TODO:语言配置后期处理
	Hashids  Hashids  `mapstructure:"hashids" json:"hashids" yaml:"hashids"`    //hash密钥等
	Captcha  Captcha  `mapstructure:"captcha" json:"captcha" yaml:"captcha"`    //验证码
}

func Get

func Get() Config

提供外部对config的访问

type Hashids

type Hashids struct {
	Length string `mapstructure:"length" json:"length" yaml:"length"` //hash长度
	Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` //hash密钥
}

type Language

type Language struct {
	Local string `mapstructure:"local" json:"local" yaml:"local"` //TODO:多语言,后期实现
}

type Mysql

type Mysql struct {
	Base       Base  `mapstructure:"base" json:"base" yaml:"base"`
	Read       Read  `mapstructure:"read" json:"read" yaml:"read"`
	Write      Write `mapstructure:"write" json:"write" yaml:"write"`
	ColIsUpper bool  `mapstructure:"colIsUpper" json:"colIsUpper" yaml:"colIsUpper"` //数据字段名称是大写还是小写
}

mysql 读写分离

type Read

type Read struct {
	Addr string `mapstructure:"addr" json:"addr" yaml:"addr"`       //mysql地址
	User string `mapstructure:"user" json:"user" yaml:"user"`       //mysql用户
	Pass string `mapstructure:"passwd" json:"passwd" yaml:"passwd"` //mysql密码
	Name string `mapstructure:"dbname" json:"dbname" yaml:"dbname"` //mysql 数据库名称
}

type Redis

type Redis struct {
	DB           int    `mapstructure:"db" json:"db" yaml:"db"`                               // redis的哪个数据库
	Addr         string `mapstructure:"addr" json:"addr" yaml:"addr"`                         // 服务器地址:端口
	Password     string `mapstructure:"password" json:"password" yaml:"password"`             // 密码
	Maxretries   int    `mapstructure:"maxretries" json:"maxretries" yaml:"maxretries"`       // 最大尝试
	Minidleconns int    `mapstructure:"minidleconns" json:"minidleconns" yaml:"minidleconns"` // 最小连接数
	Poolsize     int    `mapstructure:"poolsize" json:"poolsize" yaml:"poolsize"`             // 缓冲大小
}

type System

type System struct {
	Port          string `mapstructure:"port" json:"port" yaml:"port"`                            //服务开启端口
	IsNeedCaptcha bool   `mapstructure:"isNeedCaptcha" json:"isNeedCaptcha" yaml:"isNeedCaptcha"` //是否启用验证码
	IsCacheIncr   bool   `mapstructure:"isCacheIncr" json:"isCacheIncr" yaml:"isCacheIncr"`       //是否启用缓存生成id
	StoreModel    bool   `mapstructure:"StoreModel" json:"StoreModel" yaml:"StoreModel"`          //TODO:服务器存储方式后期实现
}

type Write

type Write struct {
	Addr string `mapstructure:"addr" json:"addr" yaml:"addr"`       //mysql地址
	User string `mapstructure:"user" json:"user" yaml:"user"`       //mysql用户
	Pass string `mapstructure:"passwd" json:"passwd" yaml:"passwd"` //mysql密码
	Name string `mapstructure:"dbname" json:"dbname" yaml:"dbname"` //mysql 数据库名称
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL