config

package
v0.0.0-...-64e5d5b Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AllowAllOrigin = "*"
View Source
const CorsDefaultMaxAgeSec = CorsMaxAgeSec
View Source
const CorsMaxAgeSec = 86400
View Source
const DefaultFileMapSize = 10
View Source
const DefaultOriginListSize = 10

Variables

This section is empty.

Functions

func IsReady

func IsReady() bool

Types

type ConfigError

type ConfigError interface {
	error
	Msg() string
	Error() string
	Warning() string
	IsError() bool
	IsWarning() bool
}

func InitConfig

func InitConfig() ConfigError

func NewConfigError

func NewConfigError(msg string) ConfigError

func NewConfigWarning

func NewConfigWarning(msg string) ConfigError

type ConfigStruct

type ConfigStruct struct {
	Yaml       YamlConfig
	File       FileLocationConfig
	CoreOrigin CorsOrigin
	// contains filtered or unexported fields
}

func Config

func Config() *ConfigStruct

func (*ConfigStruct) GetSignalChan

func (c *ConfigStruct) GetSignalChan() chan os.Signal

type CorsConfig

type CorsConfig struct {
	AllowCors      utils.StringBool `json:"allowcors"`
	AllowOrigin    []string         `json:"alloworigin"`
	AllowOriginReg []string         `json:"alloworiginres"`
	MaxAgeSec      int              `json:"maxagesec"`
}

func (*CorsConfig) Disable

func (c *CorsConfig) Disable() bool

func (*CorsConfig) Enable

func (c *CorsConfig) Enable() bool

type CorsOrigin

type CorsOrigin struct {
	OriginReg    []*regexp.Regexp
	OriginString []string
}

func (*CorsOrigin) ApplyReg

func (c *CorsOrigin) ApplyReg(origin string) error

func (*CorsOrigin) InOriginList

func (c *CorsOrigin) InOriginList(origin string) bool

func (*CorsOrigin) SetString

func (c *CorsOrigin) SetString(origins []string) error

type FileConfig

type FileConfig struct {
	LocalPath string `yaml:"localpath"`
}

type FileLocationConfig

type FileLocationConfig struct {
	Image map[modeltype.ImageType]string
	Video map[modeltype.VideoType]string
}

type FrontConfig

type FrontConfig struct {
	BasePath    string `yaml:"basepath"`
	TestPath    string `yaml:"testpath"`
	TestPayPath string `yaml:"testpaypath"`
}

type GlobalConfig

type GlobalConfig struct {
	Mode     string           `json:"mode"`
	LogLevel string           `json:"loglevel"`
	LogTag   utils.StringBool `json:"logtag"`
}

func (*GlobalConfig) GetGinMode

func (g *GlobalConfig) GetGinMode() string

func (*GlobalConfig) IsDebug

func (g *GlobalConfig) IsDebug() bool

func (*GlobalConfig) IsRelease

func (g *GlobalConfig) IsRelease() bool

func (*GlobalConfig) IsTest

func (g *GlobalConfig) IsTest() bool

type HttpConfig

type HttpConfig struct {
	Address        string           `yaml:"address"`
	DebugMsg       utils.StringBool `yaml:"debugmsg"`
	BasePath       string           `yaml:"basepath"`
	ApiPath        string           `yaml:"apipath"`
	PingPath       string           `yaml:"pingpath"`
	ResourcePath   string           `yaml:"resourcepath"`
	EnableTestAPI  string           `yaml:"enabletestapi"`
	Proxy          ProxyConfig      `yaml:"proxy"`
	StopSecret     string           `yaml:"stopsecret"`
	StopWaitSecond int              `yaml:"stopwaitsecond"`
	Cors           CorsConfig       `yaml:"cors"`
}

func (*HttpConfig) CheckStopSecret

func (h *HttpConfig) CheckStopSecret(secret string) bool

type JwtConfig

type JwtConfig struct {
	Secret     string           `json:"secret"`
	SecretPath string           `json:"secretpath"`
	SaveSecret utils.StringBool `json:"savesecret"`
	Hour       int64            `json:"hour"`
	ResetMin   int64            `json:"resetmin"`
	Issuer     string           `json:"issuer"`
}

type LoggerLevel

type LoggerLevel string

type MySQLConfig

type MySQLConfig struct {
	UserName       string           `yaml:"username"`
	Password       string           `yaml:"password"`
	Address        string           `yaml:"address"`
	Port           int64            `yaml:"port"`
	DBName         string           `yaml:"dbname"`
	ActiveShutdown utils.StringBool `yaml:"activeshutdown"`
	FakeData       utils.StringBool `yaml:"fakedata"`
}

type ParserError

type ParserError interface {
	error
	Error() string
	Data() interface{}
}

func NewParserError

func NewParserError(data interface{}, msg ...string) ParserError

func WarpParserError

func WarpParserError(err error) ParserError

type PasswordConfig

type PasswordConfig struct {
	Front   string `yaml:"front"`
	Backend string `yaml:"backend"`
}

type ProxyConfig

type ProxyConfig struct {
	Proxy      utils.StringBool `json:"proxy"`
	TrustedIPs []string         `json:"trustedips"`
}

func (*ProxyConfig) Enable

func (p *ProxyConfig) Enable() bool

type YamlConfig

type YamlConfig struct {
	GlobalConfig `yaml:",inline"`
	Mysql        MySQLConfig    `yaml:"mysql"`
	File         FileConfig     `yaml:"file"`
	Http         HttpConfig     `yaml:"http"`
	Front        FrontConfig    `yaml:"front"`
	Jwt          JwtConfig      `yaml:"jwt"`
	Password     PasswordConfig `yaml:"password"`
}

Jump to

Keyboard shortcuts

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