config

package
v0.0.0-...-c8dbcfe Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C = new(APPConfig)
)

Functions

func MustLoadAPPConfig

func MustLoadAPPConfig(fpaths ...string)

Load config file (toml/json/yaml)

func PrintWithJSON

func PrintWithJSON()

Types

type APPConfig

type APPConfig 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
}

func (*APPConfig) IsDebugMode

func (c *APPConfig) IsDebugMode() bool

type CORS

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

type Captcha

type Captcha struct {
	Store       string
	Length      int
	Width       int
	Height      int
	RedisDB     int
	RedisPrefix string
}

type Casbin

type Casbin struct {
	Enable           bool
	Debug            bool
	Model            string
	AutoLoad         bool
	AutoLoadInternal int
	DefaultPolicy    *DefaultPolicy
}

type CreatorObject

type CreatorObject struct {
	Name        string `json:"name"        toml:"name"`
	Type        string `json:"type"        toml:"type"`
	Description string `json:"description" toml:"description"`
}

type CreatorPolicy

type CreatorPolicy struct {
	Object string   `json:"object" toml:"object"`
	Role   string   `json:"role"   toml:"role"`
	Action []string `json:"action" toml:"action"`
}

type CreatorRole

type CreatorRole struct {
	Name        string `json:"name"        toml:"name"`
	Description string `json:"description" toml:"description"`
}

type DefaultPolicy

type DefaultPolicy struct {
	CreatorObject []*CreatorObject `toml:"creator_object"`
	CreatorRole   []*CreatorRole   `toml:"creator_role"`
	CreatorPolicy []*CreatorPolicy `toml:"creator_policy"`
}

func NewDefaultPolicyByFile

func NewDefaultPolicyByFile(policypath string) (*DefaultPolicy, error)

func (*DefaultPolicy) GetCreatorObject

func (f *DefaultPolicy) GetCreatorObject() ([]*CreatorObject, error)

func (*DefaultPolicy) GetCreatorPolicy

func (f *DefaultPolicy) GetCreatorPolicy() ([]*CreatorPolicy, error)

func (*DefaultPolicy) GetCreatorRole

func (f *DefaultPolicy) GetCreatorRole() ([]*CreatorRole, error)

type GZIP

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

type Gorm

type Gorm struct {
	Debug             bool
	DBType            string
	MaxLifetime       int
	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 {
	Enable        bool
	SigningMethod string
	SigningKey    string
	Expired       int
	Store         string
	FilePath      string
	RedisDB       int
	RedisPrefix   string
}

type Log

type Log struct {
	Level         int
	Format        string
	Output        string
	OutputFile    string
	EnableHook    bool
	HookLevels    []string
	Hook          LogHook
	HookMaxThread int
	HookMaxBuffer int
	RotationCount int
	RotationTime  int
}

type LogGormHook

type LogGormHook struct {
	DBType       string
	MaxLifetime  int
	MaxOpenConns int
	MaxIdleConns int
	Table        string
}

type LogHook

type LogHook string

func (LogHook) IsGorm

func (h LogHook) IsGorm() bool

type LogMongoHook

type LogMongoHook struct {
	Collection string
}
type Menu struct {
	Enable bool
	Data   string
}

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 Postgres

type Postgres struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  string
}

func (Postgres) DSN

func (a Postgres) DSN() string

type RateLimiter

type RateLimiter struct {
	Enable  bool
	Count   int64
	RedisDB int
}

type Redis

type Redis struct {
	Addr     string
	Password string
}

type Root

type Root struct {
	MemberID   uint64
	MemberName string
	Password   string
	RealName   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