config

package
v0.0.0-...-831d175 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGlobalConfig

func LoadGlobalConfig(fpath string) error

LoadGlobalConfig 加载全局配置

Types

type CORS

type CORS struct {
	Enable           bool     `toml:"enable"`
	AllowOrigins     []string `toml:"allow_origins"`
	AllowMethods     []string `toml:"allow_methods"`
	AllowHeaders     []string `toml:"allow_headers"`
	AllowCredentials bool     `toml:"allow_credentials"`
	MaxAge           int      `toml:"max_age"`
}

CORS 跨域请求配置参数

type Captcha

type Captcha struct {
	Store       string `toml:"store"`
	Length      int    `toml:"length"`
	Width       int    `toml:"width"`
	Height      int    `toml:"height"`
	RedisDB     int    `toml:"redis_db"`
	RedisPrefix string `toml:"redis_prefix"`
}

Captcha 图形验证码配置参数

type Config

type Config struct {
	RunMode         string      `toml:"run_mode"`
	CasbinModelConf string      `toml:"casbin_model_conf"`
	WWW             string      `toml:"www"`
	Swagger         string      `toml:"swagger"`
	Store           string      `toml:"store"`
	AllowInitMenu   bool        `toml:"allow_init_menu"`
	EnableCasbin    bool        `toml:"enable_casbin"`
	Log             Log         `toml:"log"`
	LogGormHook     LogGormHook `toml:"log_gorm_hook"`
	Root            Root        `toml:"root"`
	JWTAuth         JWTAuth     `toml:"jwt_auth"`
	HTTP            HTTP        `toml:"http"`
	Monitor         Monitor     `toml:"monitor"`
	Captcha         Captcha     `toml:"captcha"`
	RateLimiter     RateLimiter `toml:"rate_limiter"`
	CORS            CORS        `toml:"cors"`
	Redis           Redis       `toml:"redis"`
	Gorm            Gorm        `toml:"gorm"`
	MySQL           MySQL       `toml:"mysql"`
	Postgres        Postgres    `toml:"postgres"`
	Sqlite3         Sqlite3     `toml:"sqlite3"`
}

Config 配置参数

func GetGlobalConfig

func GetGlobalConfig() *Config

GetGlobalConfig 获取全局配置

func ParseConfig

func ParseConfig(fpath string) (*Config, error)

ParseConfig 解析配置文件

type Gorm

type Gorm struct {
	Debug        bool   `toml:"debug"`
	DBType       string `toml:"db_type"`
	MaxLifetime  int    `toml:"max_lifetime"`
	MaxOpenConns int    `toml:"max_open_conns"`
	MaxIdleConns int    `toml:"max_idle_conns"`
	TablePrefix  string `toml:"table_prefix"`
}

Gorm gorm配置参数

type HTTP

type HTTP struct {
	Host            string `toml:"host"`
	Port            int    `toml:"port"`
	ShutdownTimeout int    `toml:"shutdown_timeout"`
}

HTTP http配置参数

type JWTAuth

type JWTAuth struct {
	SigningMethod string `toml:"signing_method"`
	SigningKey    string `toml:"signing_key"`
	Expired       int    `toml:"expired"`
	Store         string `toml:"store"`
	FilePath      string `toml:"file_path"`
	RedisDB       int    `toml:"redis_db"`
	RedisPrefix   string `toml:"redis_prefix"`
}

JWTAuth 用户认证

type Log

type Log struct {
	Level         int    `toml:"level"`
	Format        string `toml:"format"`
	Output        string `toml:"output"`
	OutputFile    string `toml:"output_file"`
	EnableHook    bool   `toml:"enable_hook"`
	Hook          string `toml:"hook"`
	HookMaxThread int    `toml:"hook_max_thread"`
	HookMaxBuffer int    `toml:"hook_max_buffer"`
}

Log 日志配置参数

type LogGormHook

type LogGormHook struct {
	DBType       string `toml:"db_type"`
	MaxLifetime  int    `toml:"max_lifetime"`
	MaxOpenConns int    `toml:"max_open_conns"`
	MaxIdleConns int    `toml:"max_idle_conns"`
	Table        string `toml:"table"`
}

LogGormHook 日志gorm钩子配置

type Monitor

type Monitor struct {
	Enable    bool   `toml:"enable"`
	Addr      string `toml:"addr"`
	ConfigDir string `toml:"config_dir"`
}

Monitor 监控配置参数

type MySQL

type MySQL struct {
	Host       string `toml:"host"`
	Port       int    `toml:"port"`
	User       string `toml:"user"`
	Password   string `toml:"password"`
	DBName     string `toml:"db_name"`
	Parameters string `toml:"parameters"`
}

MySQL mysql配置参数

func (MySQL) DSN

func (a MySQL) DSN() string

DSN 数据库连接串

type Postgres

type Postgres struct {
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
	User     string `toml:"user"`
	Password string `toml:"password"`
	DBName   string `toml:"db_name"`
	SSLMode  string `toml:"sslmode"`
}

Postgres postgres配置参数

func (Postgres) DSN

func (a Postgres) DSN() string

DSN 数据库连接串

type RateLimiter

type RateLimiter struct {
	Enable  bool  `toml:"enable"`
	Count   int64 `toml:"count"`
	RedisDB int   `toml:"redis_db"`
}

RateLimiter 请求频率限制配置参数

type Redis

type Redis struct {
	Addr     string `toml:"addr"`
	Password string `toml:"password"`
}

Redis redis配置参数

type Root

type Root struct {
	UserName string `toml:"user_name"`
	Password string `toml:"password"`
	RealName string `toml:"real_name"`
}

Root root用户

type Sqlite3

type Sqlite3 struct {
	Path string `toml:"path"`
}

Sqlite3 sqlite3配置参数

func (Sqlite3) DSN

func (a Sqlite3) DSN() string

DSN 数据库连接串

Jump to

Keyboard shortcuts

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