config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGlobal

func LoadGlobal(fpath string) error

LoadGlobal 加载全局配置

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 Casbin

type Casbin struct {
	Enable           bool   `toml:"enable"`
	Debug            bool   `toml:"debug"`
	Model            string `toml:"model"`
	AutoLoad         bool   `toml:"auto_load"`
	AutoLoadInternal int    `toml:"auto_load_internal"`
}

Casbin casbin配置参数

type Config

type Config struct {
	RunMode     string      `toml:"run_mode"`
	WWW         string      `toml:"www"`
	Swagger     string      `toml:"swagger"`
	Store       string      `toml:"store"`
	HTTP        HTTP        `toml:"http"`
	Menu        Menu        `toml:"menu"`
	Casbin      Casbin      `toml:"casbin"`
	Log         Log         `toml:"log"`
	LogGormHook LogGormHook `toml:"log_gorm_hook"`
	Root        Root        `toml:"root"`
	JWTAuth     JWTAuth     `toml:"jwt_auth"`
	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 Global

func Global() *Config

Global 获取全局配置

func Parse

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

Parse 解析配置文件

func (*Config) IsDebugMode

func (c *Config) IsDebugMode() bool

IsDebugMode 是否是debug模式

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"`
	EnableAutoMigrate bool   `toml:"enable_auto_migrate"`
}

Gorm gorm配置参数

type HTTP

type HTTP struct {
	Host            string `toml:"host"`
	Port            int    `toml:"port"`
	CertFile        string `toml:"cert_file"`
	KeyFile         string `toml:"key_file"`
	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 Menu struct {
	Enable bool   `toml:"enable"`
	Data   string `toml:"data"`
}

Menu 菜单配置参数

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:"ssl_mode"`
}

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