config

package
v2.0.77 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// C 全局配置(需要先执行MustLoad,否则拿不到配置)
	C = new(Config)
)

Functions

func MustLoad

func MustLoad(path string)

MustLoad 加载配置

func PrintWithJSON

func PrintWithJSON()

PrintWithJSON 基于JSON格式输出配置

Types

type AgentServiceCheck added in v2.0.58

type AgentServiceCheck struct {
	Timeout                        int
	Interval                       int
	DeregisterCriticalServiceAfter int
}

type AgentServiceRegistration added in v2.0.58

type AgentServiceRegistration struct {
	ID      int
	Name    string
	Port    int
	Tags    []string
	Address string
}

type CORS

type CORS struct {
	Enable           bool
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials bool
	MaxAge           int
	ExposeHeaders    []string
}

CORS 跨域请求配置参数

type Captcha

type Captcha struct {
	Store       string
	Length      int
	Width       int
	Height      int
	RedisDB     int
	RedisPrefix string
}

Captcha 图形验证码配置参数

type Casbin

type Casbin struct {
	Enable           bool
	Debug            bool
	Model            string
	AutoLoad         bool
	AutoLoadInternal int
}

Casbin casbin配置参数

type Config

type Config struct {
	RunMode     string
	EnableDP    bool
	WWW         string
	Version     string
	Swagger     bool
	PrintConfig bool
	Solt        string
	AESKey      string
	Server      Server
	Casbin      Casbin
	Log         Log
	LogGormHook LogGormHook
	JWTAuth     JWTAuth
	Monitor     Monitor
	Captcha     Captcha
	RateLimiter RateLimiter
	CORS        CORS
	GZIP        GZIP
	Redis       Redis
	Gorm        Gorm
	MySQLs      MySQLs
	Postgress   Postgress
	Sqlite3s    Sqlite3s
	Generate    Generate
	Oss         OSS
	Transcode   Transcode
	DBBackUp    DBBackUp
	Consul      Consul
}

Config 配置参数

func (*Config) IsDebugMode

func (c *Config) IsDebugMode() bool

IsDebugMode 是否是debug模式

type Consul added in v2.0.58

type Consul struct {
	Enable       bool
	Address      string
	Registration AgentServiceRegistration
	Check        AgentServiceCheck
}

type DBBackUp added in v2.0.55

type DBBackUp struct {
	StorageRoot string
}

DBBackup 数据库备份

type GZIP

type GZIP struct {
	Enable             bool
	ExcludedExtentions []string
	ExcludedPaths      []string
}

GZIP gzip压缩

type Generate

type Generate struct {
	DBName    string
	FrontPath string
}

Generate 代码生成结构

type Gorm

type Gorm struct {
	Debug             bool
	DBType            string
	MaxLifetime       int
	MaxOpenConns      int
	MaxIdleConns      int
	TablePrefix       string
	EnableAutoMigrate bool
}

Gorm gorm配置参数

func (*Gorm) DSN

func (g *Gorm) DSN(index string) string

DSN Gorm DSN 数据库连接串

type JWTAuth

type JWTAuth struct {
	Enable             bool
	SigningMethod      string
	SigningKey         string
	Expired            int
	Store              string
	FilePath           string
	RedisDB            int
	RedisPrefix        string
	NoAuthPaths        []string
	NoPerimissionPaths []string
}

JWTAuth 用户认证

type Log

type Log struct {
	Level         int
	Format        string
	Output        string
	OutputFile    string
	EnableHook    bool
	HookLevels    []string
	Hook          LogHook
	HookMaxThread int
	HookMaxBuffer int
}

Log 日志配置参数

type LogGormHook

type LogGormHook struct {
	DBType       string
	MaxLifetime  int
	MaxOpenConns int
	MaxIdleConns int
	Table        string
}

LogGormHook 日志钩子配置

type LogHook

type LogHook string

LogHook 日志钩子

func (LogHook) IsGorm

func (h LogHook) IsGorm() bool

IsGorm 是否是gorm钩子

type Monitor

type Monitor struct {
	Enable    bool
	Addr      string
	ConfigDir string
}

Monitor 监控配置参数

type MySQL

type MySQL struct {
	Host       string
	Port       int
	User       string
	Password   string
	DBName     string
	Parameters string
}

MySQL mysql配置参数

func (MySQL) DSN

func (a MySQL) DSN() string

DSN 数据库连接串

type MySQLs

type MySQLs map[string]*MySQL

MySQLs 多数据库

func (MySQLs) DSN

func (m MySQLs) DSN(index string) string

DSN 根据索引获取DSN

type OSS

type OSS struct {
	Enable           bool
	TLS              bool
	Type             string // 支持类型minio、aliyun、huawei、local; local:本地文件存储
	Endpoint         string
	AccessKeyID      string
	SecretAccessKey  string
	BucketName       string
	ObjectNameFormat string
	SecurityToken    string // 仅对华为OBS需要
	StorageRoot      string // 仅对本地(local)文件存储需要
	CDN              string
}

OSS oss存储

type Postgres

type Postgres struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  string
}

Postgres postgres配置参数

func (Postgres) DSN

func (a Postgres) DSN() string

DSN 数据库连接串

type Postgress

type Postgress map[string]*Postgres

Postgress 多数据库

func (Postgress) DSN

func (p Postgress) DSN(index string) string

DSN 根据索引获取DSN

type RateLimiter

type RateLimiter struct {
	Enable  bool
	Count   int
	RedisDB int
}

RateLimiter 请求频率限制配置参数

type Redis

type Redis struct {
	Addr     string
	Password string
}

Redis redis配置参数

type Server

type Server struct {
	Host             string
	Port             int
	CertFile         string
	KeyFile          string
	ShutdownTimeout  int
	MaxContentLength int64
	MaxLoggerLength  int
}

Server Server配置参数

type Sqlite3

type Sqlite3 struct {
	Path string
}

Sqlite3 sqlite3配置参数

func (Sqlite3) DSN

func (a Sqlite3) DSN() string

DSN 数据库连接串

type Sqlite3s

type Sqlite3s map[string]*Sqlite3

Sqlite3s 多数据库

func (Sqlite3s) DSN

func (s Sqlite3s) DSN(index string) string

DSN 根据索引获取DSN

type Transcode added in v2.0.22

type Transcode struct {
	Type       string // 支持类型aliyun、ffmpeg
	CDN        string
	API        string
	BucketName string
}

Transcode 转码

Jump to

Keyboard shortcuts

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