config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 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 - Load global configuration

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 Cross-domain request configuration parameters

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 - Graphic verification code configuration parameter

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 configuration parameters

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"`
	I18n        i18n        `toml:"i18n"`
	Permission  Permission  `toml:"permission"`
	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 parameters

func Global

func Global() *Config

Global - Get global configuration

func Parse

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

Parse configuration file

func (*Config) IsDebugMode

func (c *Config) IsDebugMode() bool

IsDebugMode - Is it debug mode?

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 configuration parameters

type HTTP

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

HTTP configuration parameters

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 User Authentication

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 configuration parameters

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

Log Gorm Hook configuration

type Monitor

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

Monitor configuration parameters

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 configuration parameters

func (MySQL) DSN

func (a MySQL) DSN() string

DSN Database connection string

type Permission

type Permission struct {
	Enable bool   `toml:"enable"`
	Data   string `toml:"data"`
}

Permission configuration parameters

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 Configuration parameter

func (Postgres) DSN

func (a Postgres) DSN() string

DSN Database connection string

type RateLimiter

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

RateLimiter - Request frequency limit configuration parameter

type Redis

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

Redis configuration parameters

type Root

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

Root User

type Sqlite3

type Sqlite3 struct {
	Path string `toml:"path"`
	Name string `toml:"name"`
	Dir  string `toml:"dir"`
}

Sqlite3 configuration parameter

func (Sqlite3) DSN

func (a Sqlite3) DSN() string

DSN Database connection string

Jump to

Keyboard shortcuts

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