config

package
v0.0.0-...-7c619cd Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C = new(Config)
)

Functions

func MustLoad

func MustLoad(fpaths ...string)

MustLoad Load config file (toml/json/yaml)

func PrintWithJSON

func PrintWithJSON()

Types

type CORS

type CORS struct {
	Enable           bool
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials bool
	MaxAge           time.Duration
}

type Config

type Config struct {
	RunMode     string
	LocalPath   string
	Swagger     bool
	PrintConfig bool
	HTTP        HTTP
	Log         Log
	JWTAuth     JWTAuth
	Monitor     Monitor
	RateLimiter RateLimiter
	CORS        CORS
	GZIP        GZIP
	Redis       Redis
	Gorm        Gorm
	MySQL       MySQL
	Sqlite3     Sqlite3
}

func (*Config) IsDebugMode

func (c *Config) IsDebugMode() bool

type GZIP

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

type Gorm

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

type HTTP

type HTTP struct {
	Host               string
	Port               int
	CertFile           string
	KeyFile            string
	ShutdownTimeout    int
	MaxContentLength   int64
	MaxReqLoggerLength int `default:"1024"`
	MaxResLoggerLength int
}

type JWTAuth

type JWTAuth struct {
	Realm       string
	Key         string
	Expired     time.Duration
	IdentityKey string
}

type Log

type Log struct {
	Level         int
	Format        string
	Output        string
	OutputFile    string
	RotationCount int
	RotationTime  int
}

type LogHook

type LogHook string

func (LogHook) IsGorm

func (h LogHook) IsGorm() bool

type Monitor

type Monitor struct {
	Enable    bool
	Addr      string
	ConfigDir string
}

type MySQL

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

func (MySQL) DSN

func (a MySQL) DSN() string

type RateLimiter

type RateLimiter struct {
	Enable  bool
	Count   int64
	RedisDB int
}

type Redis

type Redis struct {
	Addr     string
	Password string
}

type Sqlite3

type Sqlite3 struct {
	Path string
}

func (Sqlite3) DSN

func (a Sqlite3) DSN() string

Jump to

Keyboard shortcuts

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