config

package
v0.0.0-...-f53b5d5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheCfg

func CacheCfg() map[string]Cache

func Cfg

func Cfg(path string) interface{}

func DBCfg

func DBCfg() map[string]DB

func FileCfg

func FileCfg() map[string]File

func Init

func Init(cfgFilePath ...string)

Types

type AliyunOSS

type AliyunOSS struct {
	Endpoint        string `json:"endpoint" yaml:"endpoint"`
	AccessKeyId     string `json:"accessKeyId" yaml:"accessKeyId"`
	AccessKeySecret string `json:"accessKeySecret" yaml:"accessKeySecret"`
	BucketName      string `json:"bucketName" yaml:"bucketName"`
	BucketUrl       string `json:"bucketUrl" yaml:"bucketUrl"`
	BasePath        string `json:"basePath" yaml:"basePath"`
}

type AwsS3

type AwsS3 struct {
	Bucket           string `json:"bucket" yaml:"bucket"`
	Region           string `json:"region" yaml:"region"`
	Endpoint         string `json:"endpoint" yaml:"endpoint"`
	S3ForcePathStyle bool   `json:"s3ForcePathStyle" yaml:"s3ForcePathStyle"`
	DisableSSL       bool   `json:"disableSsl" yaml:"disableSsl"`
	SecretID         string `json:"secretId" yaml:"secretId"`
	SecretKey        string `json:"secretKey" yaml:"secretKey"`
	BaseURL          string `json:"baseUrl" yaml:"baseUrl"`
	PathPrefix       string `json:"pathPrefix" yaml:"pathPrefix"`
}

type CORS

type CORS struct {
	Mode      string          `json:"mode" yaml:"mode"`
	Whitelist []CORSWhitelist `json:"whitelist" yaml:"whitelist"`
}

func CORSCfg

func CORSCfg() CORS

type CORSWhitelist

type CORSWhitelist struct {
	AllowOrigin      string `json:"allowOrigin" yaml:"allowOrigin"`
	AllowMethods     string `json:"allowMethods" yaml:"allowMethods"`
	AllowHeaders     string `json:"allowHeaders" yaml:"allowHeaders"`
	ExposeHeaders    string `json:"exposeHeaders" yaml:"exposeHeaders"`
	AllowCredentials bool   `json:"allowCredentials" yaml:"allowCredentials"`
}

type Cache

type Cache struct {
	DB       int    `json:"db" yaml:"db"`             // 数据库index
	Addr     string `json:"addr" yaml:"addr"`         // 服务器地址:端口
	Password string `json:"password" yaml:"password"` // 密码
}

type Captcha

type Captcha struct {
	KeyLong            int `json:"keyLong" yaml:"keyLong"`                       // 验证码长度
	ImgWidth           int `json:"imgWidth" yaml:"imgWidth"`                     // 验证码宽度
	ImgHeight          int `json:"imgHeight" yaml:"imgHeight"`                   // 验证码高度
	OpenCaptcha        int `json:"openCaptcha" yaml:"openCaptcha"`               // 防爆破验证码开启此数,0代表每次登录都需要验证码,其他数字代表错误密码此数,如3代表错误三次后出现验证码
	OpenCaptchaTimeOut int `json:"openCaptchaTimeout" yaml:"openCaptchaTimeout"` // 防爆破验证码超时时间,单位:s(秒)
}

func CaptchaCfg

func CaptchaCfg() Captcha

type Config

type Config struct {
	Server  Server           `json:"server,omitempty" yaml:"server,omitempty"`
	CORS    CORS             `json:"cors,omitempty" yaml:"cors,omitempty"`
	Jwt     Jwt              `json:"jwt,omitempty" yaml:"jwt,omitempty"`
	Captcha Captcha          `json:"captcha,omitempty" yaml:"captcha,omitempty"`
	Log     Log              `json:"log,omitempty" yaml:"log,omitempty"`
	DB      map[string]DB    `json:"db,omitempty" yaml:"db,omitempty"`
	Cache   map[string]Cache `json:"cache,omitempty" yaml:"cache,omitempty"`
	File    map[string]File  `json:"file,omitempty" yaml:"file,omitempty"`
}

type DB

type DB struct {
	Driver      string `json:"driver" yaml:"driver"`           // 驱动
	Path        string `json:"path" yaml:"path"`               // 服务器地址
	Port        string `json:"port" yaml:"port"`               //端口
	Config      string `json:"config" yaml:"config"`           // 高级配置
	Dbname      string `json:"dbname" yaml:"dbname"`           // 数据库名
	Username    string `json:"username" yaml:"username"`       // 数据库用户名
	Password    string `json:"password" yaml:"password"`       // 数据库密码
	Prefix      string `json:"prefix" yaml:"prefix"`           //全局表前缀,单独定义TableName则不生效
	Singular    bool   `json:"singular" yaml:"singular"`       //是否开启全局禁用复数,true表示开启
	MaxIdleConn int    `json:"maxIdleConn" yaml:"maxIdleConn"` // 空闲中的最大连接数
	MaxOpenConn int    `json:"maxOpenConn" yaml:"maxOpenConn"` // 打开到数据库的最大连接数
	LogMode     int    `json:"logMode" yaml:"logMode"`         // 日志等级 Silent:1;Error:2;Warn:3;Info:4
}

func (*DB) Dialector

func (g *DB) Dialector() gorm.Dialector

type File

type File struct {
	Name       string  `json:"name" yaml:"name"`
	Driver     string  `json:"driver" yaml:"driver"`         // 类型 cos:腾讯云COS; oss:阿里云OSS; local:本地文件存储;
	Bucket     string  `json:"bucket" yaml:"bucket"`         // 储存桶
	Region     string  `json:"region" yaml:"region"`         // 地域: 腾讯:region; 阿里:Endpoint;
	ID         string  `json:"id" yaml:"id"`                 // id
	Key        string  `json:"key" yaml:"key"`               // key
	PrefixPath string  `json:"prefixPath" yaml:"prefixPath"` // 文件访问前缀
	StorePath  string  `json:"storePath" yaml:"storePath"`   // 本地文件存储路径(类型为local时必填)
	CdnURL     string  `json:"cdnUrl" yaml:"cdnUrl"`         // 文件访问CND域名
	Limit      float64 `json:"limit" yaml:"limit"`
}

type Jwt

type Jwt struct {
	SigningKey  string `json:"signingKey" yaml:"signingKey"`   // jwt签名
	ExpiresTime string `json:"expiresTime" yaml:"expiresTime"` // 过期时间
	BufferTime  string `json:"bufferTime" yaml:"bufferTime"`   // 缓冲时间
	Issuer      string `json:"issuer" yaml:"issuer"`           // 签发者
}

func JwtCfg

func JwtCfg() Jwt

type Local

type Local struct {
	Path      string `json:"path" yaml:"path"`           // 本地文件访问路径
	StorePath string `json:"storePath" yaml:"storePath"` // 本地文件存储路径
}

type Log

type Log struct {
	Prefix      string   `json:"prefix" yaml:"prefix"`           // 日志前缀
	MaxAge      int      `json:"maxAge" yaml:"maxAge"`           // 日志留存时间
	Level       string   `json:"level" yaml:"level"`             // 级别 debug/info/warn/error/dpanic/panic/fatal
	Format      string   `json:"format" yaml:"format"`           // 输出形式 json/console
	EncodeLevel uint8    `json:"encodeLevel" yaml:"encodeLevel"` // 编码形式
	Output      []string `json:"output" yaml:"output"`           // 输出形式 console(stdout)/youDirName/TODO 对接日志接收器
}

func LogCfg

func LogCfg() Log

func (Log) TransportLevel

func (l Log) TransportLevel() zapcore.Level

func (Log) ZapEncodeLevel

func (l Log) ZapEncodeLevel() zapcore.LevelEncoder

type Qiniu

type Qiniu struct {
	Zone          string `json:"zone" yaml:"zone"`                   // 存储区域
	Bucket        string `json:"bucket" yaml:"bucket"`               // 空间名称
	ImgPath       string `json:"imgPath" yaml:"imgPath"`             // CDN加速域名
	UseHTTPS      bool   `json:"useHttps" yaml:"useHttps"`           // 是否使用https
	AccessKey     string `json:"accessKey" yaml:"accessKey"`         // 秘钥AK
	SecretKey     string `json:"secretKey" yaml:"secretKey"`         // 秘钥SK
	UseCdnDomains bool   `json:"useCdnDomains" yaml:"useCdnDomains"` // 上传是否使用CDN上传加速
}

type Server

type Server struct {
	Name              string `json:"name" yaml:"name"`
	Env               string `json:"env" yaml:"env"`                             // 运行环境
	Host              string `json:"host" yaml:"host"`                           // 监听地址
	Port              int    `json:"port" yaml:"port"`                           // 端口值
	UseMultipoint     bool   `json:"useMultipoint" yaml:"useMultipoint"`         // 多点登录拦截
	FrontHost         string `json:"frontHost" yaml:"frontHost"`                 // 前后端分离部署时,指向前端主页
	FrontRouterPrefix string `json:"frontRouterPrefix" yaml:"frontRouterPrefix"` // 前端项目前缀
	Endless           bool   `json:"endless" yaml:"endless"`                     // 通过endless启动
}

func ServerCfg

func ServerCfg() Server

type TencentCOS

type TencentCOS struct {
	Bucket    string `json:"bucket" yaml:"bucket"`       // 储存桶
	Region    string `json:"region" yaml:"region"`       // 地域
	SecretID  string `json:"secretId" yaml:"secretId"`   // id
	SecretKey string `json:"secretKey" yaml:"secretKey"` // key
	BaseURL   string `json:"baseUrl" yaml:"baseUrl"`     // 文件访问CND域名
}

Jump to

Keyboard shortcuts

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