config

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = Configuration{}

Functions

func Run

func Run(cfg string) error

Types

type CasbinConfiguration

type CasbinConfiguration struct {
	ModelPath string `mapstructure:"model-path" json:"modelPath"`
}

type Configuration

type Configuration struct {
	System    SystemConfiguration    `mapstructure:"system" json:"system"`
	Logs      LogsConfiguration      `mapstructure:"logs" json:"logs"`
	Mysql     MysqlConfiguration     `mapstructure:"mysql" json:"mysql"`
	Redis     RedisConfiguration     `mapstructure:"redis" json:"redis"`
	Casbin    CasbinConfiguration    `mapstructure:"casbin" json:"casbin"`
	Jwt       JwtConfiguration       `mapstructure:"jwt" json:"jwt"`
	RateLimit RateLimitConfiguration `mapstructure:"rate-limit" json:"rateLimit"`
	Upload    UploadConfiguration    `mapstructure:"upload" json:"upload"`
	Wechat    WechatConfiguration    `mapstructure:"wechat" json:"wechat"`
}

系统配置, 配置字段可参见yml注释 viper 内置了mapstructure, yml文件用"-"区分单词, 转为驼峰方便

type JwtConfiguration

type JwtConfiguration struct {
	Realm      string `mapstructure:"realm" json:"realm"`
	Key        string `mapstructure:"key" json:"key"`
	Timeout    int    `mapstructure:"timeout" json:"timeout"`
	MaxRefresh int    `mapstructure:"max-refresh" json:"maxRefresh"`
}

type LogsConfiguration

type LogsConfiguration struct {
	Level      string `mapstructure:"level" json:"level"`
	Path       string `mapstructure:"path" json:"path"`
	MaxSize    int    `mapstructure:"max-size" json:"maxSize"`
	MaxBackups int    `mapstructure:"max-backups" json:"maxBackups"`
	MaxAge     int    `mapstructure:"max-age" json:"maxAge"`
	Compress   bool   `mapstructure:"compress" json:"compress"`
}

type MysqlConfiguration

type MysqlConfiguration struct {
	Username    string `mapstructure:"username" json:"username"`
	Password    string `mapstructure:"password" json:"password"`
	Database    string `mapstructure:"database" json:"database"`
	Host        string `mapstructure:"host" json:"host"`
	Port        int    `mapstructure:"port" json:"port"`
	Query       string `mapstructure:"query" json:"query"`
	LogMode     bool   `mapstructure:"log-mode" json:"logMode"`
	TablePrefix string `mapstructure:"table-prefix" json:"tablePrefix"`
	Charset     string `mapstructure:"charset" json:"charset"`
	Collation   string `mapstructure:"collation" json:"collation"`
}

type RateLimitConfiguration

type RateLimitConfiguration struct {
	Max int64 `mapstructure:"max" json:"max"`
}

type RedisConfiguration

type RedisConfiguration struct {
	Host      string `mapstructure:"host" json:"host"`
	Port      int    `mapstructure:"port" json:"port"`
	Password  string `mapstructure:"password" json:"password"`
	Database  int    `mapstructure:"database" json:"database"`
	BinlogPos string `mapstructure:"binlog-pos" json:"binlogPos"`
}

type SystemConfiguration

type SystemConfiguration struct {
	UrlPathPrefix               string   `mapstructure:"url-path-prefix" json:"urlPathPrefix"`
	ApiVersion                  string   `mapstructure:"api-version" json:"apiVersion"`
	Port                        int      `mapstructure:"port" json:"port"`
	PprofPort                   int      `mapstructure:"pprof-port" json:"pprofPort"`
	ConnectTimeout              int      `mapstructure:"connect-timeout" json:"connectTimeout"`
	UseRedis                    bool     `mapstructure:"use-redis" json:"useRedis"`
	UseRedisService             bool     `mapstructure:"use-redis-service" json:"useRedisService"`
	Transaction                 bool     `mapstructure:"transaction" json:"transaction"`
	InitData                    bool     `mapstructure:"init-data" json:"initData"`
	OperationLogKey             string   `mapstructure:"operation-log-key" json:"operationLogKey"`
	OperationLogDisabledPaths   string   `mapstructure:"operation-log-disabled-paths" json:"operationLogDisabledPaths"`
	OperationLogDisabledPathArr []string `mapstructure:"-" json:"-"`
	OperationLogAllowedToDelete bool     `mapstructure:"operation-log-allowed-to-delete" json:"operationLogAllowedToDelete"`
	RSAPublicKey                string   `mapstructure:"rsa-public-key" json:"rsaPublicKey"`
	RSAPrivateKey               string   `mapstructure:"rsa-private-key" json:"rsaPrivateKey"`
	RSAPublicBytes              []byte   `mapstructure:"-" json:"-"`
	RSAPrivateBytes             []byte   `mapstructure:"-" json:"-"`
	IdempotenceTokenName        string   `mapstructure:"idempotence-token-name" json:"idempotenceTokenName"`
}

type UploadConfiguration

type UploadConfiguration struct {
	Minio                        UploadOssMinioConfiguration `mapstructure:"oss-minio" json:"ossMinio"`
	SaveDir                      string                      `mapstructure:"save-dir" json:"saveDir"`
	SingleMaxSize                uint                        `mapstructure:"single-max-size" json:"singleMaxSize"`
	MergeConcurrentCount         uint                        `mapstructure:"merge-concurrent-count" json:"mergeConcurrentCount"`
	CompressImageCronTask        string                      `mapstructure:"compress-image-cron-task" json:"compressImageCronTask"`
	CompressImageRootDir         string                      `mapstructure:"compress-image-root-dir" json:"compressImageRootDir"`
	CompressImageOriginalSaveDir string                      `mapstructure:"compress-image-original-save-dir" json:"compressImageOriginalSaveDir"`
}

type UploadOssMinioConfiguration

type UploadOssMinioConfiguration struct {
	Enable   bool   `mapstructure:"enable" json:"enable"`
	Bucket   string `mapstructure:"bucket" json:"bucket"`
	Endpoint string `mapstructure:"endpoint" json:"endpoint"`
	AccessId string `mapstructure:"access-id" json:"accessId"`
	Secret   string `mapstructure:"secret" json:"secret"`
	UseHttps bool   `mapstructure:"use-https" json:"useHttps"`
}

type WechatConfiguration

type WechatConfiguration struct {
	Official WechatOfficialConfiguration `mapstructure:"official" json:"official"`
}

type WechatOfficialConfiguration

type WechatOfficialConfiguration struct {
	AppId              string                                        `mapstructure:"app-id" json:"appId"`
	AppSecret          string                                        `mapstructure:"app-secret" json:"appSecret"`
	Encoding           string                                        `mapstructure:"encoding" json:"encoding"`
	TplMessageCronTask WechatOfficialTplMessageCronTaskConfiguration `mapstructure:"tpl-message-cron-task" json:"tplMessageCronTask"`
}

type WechatOfficialTplMessageCronTaskConfiguration

type WechatOfficialTplMessageCronTaskConfiguration struct {
	Expr                string `mapstructure:"expr" json:"expr"`
	Users               string `mapstructure:"users" json:"users"`
	TemplateId          string `mapstructure:"template-id" json:"templateId"`
	MiniProgramAppId    string `mapstructure:"mini-program-app-id" json:"miniProgramAppId"`
	MiniProgramPagePath string `mapstructure:"mini-program-page-path" json:"miniProgramPagePath"`
}

Jump to

Keyboard shortcuts

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