config

package
v7.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func MustLoad

func MustLoad(fpaths ...string)

MustLoad 加载配置

func PrintWithJSON

func PrintWithJSON()

PrintWithJSON 基于JSON格式输出配置

Types

type CORS

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

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
	WWW          string
	Swagger      bool
	PrintConfig  bool
	HTTP         HTTP
	Menu         Menu
	Casbin       Casbin
	Log          Log
	LogGormHook  LogGormHook
	LogMongoHook LogMongoHook
	Root         Root
	JWTAuth      JWTAuth
	Monitor      Monitor
	Captcha      Captcha
	RateLimiter  RateLimiter
	CORS         CORS
	GZIP         GZIP
	Redis        Redis
	Gorm         Gorm
	MySQL        MySQL
	Postgres     Postgres
	Sqlite3      Sqlite3
}

Config 配置参数

func (*Config) IsDebugMode

func (c *Config) IsDebugMode() bool

IsDebugMode 是否是debug模式

type GZIP

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

GZIP gzip压缩

type Gorm

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

Gorm gorm配置参数

type HTTP

type HTTP struct {
	Host             string
	Port             int
	CertFile         string
	KeyFile          string
	ShutdownTimeout  int
	MaxContentLength int64
	MaxLoggerLength  int `default:"4096"`
}

HTTP http配置参数

type JWTAuth

type JWTAuth struct {
	Enable        bool
	SigningMethod string
	SigningKey    string
	Expired       int
	Store         string
	FilePath      string
	RedisDB       int
	RedisPrefix   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 日志gorm钩子配置

type LogHook

type LogHook string

LogHook 日志钩子

func (LogHook) IsGorm

func (h LogHook) IsGorm() bool

IsGorm 是否是gorm钩子

func (LogHook) IsMongo

func (h LogHook) IsMongo() bool

IsMongo 是否是mongo钩子

type LogMongoHook

type LogMongoHook struct {
	Collection string
}

LogMongoHook 日志mongo钩子配置

type Menu struct {
	Enable bool
	Data   string
}

Menu 菜单配置参数

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 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 RateLimiter

type RateLimiter struct {
	Enable  bool
	Count   int64
	RedisDB int
}

RateLimiter 请求频率限制配置参数

type Redis

type Redis struct {
	Addr     string
	Password string
}

Redis redis配置参数

type Root

type Root struct {
	UserName string
	Password string
	RealName string
}

Root root用户

type Sqlite3

type Sqlite3 struct {
	Path string
}

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