settings

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_NAME           = "blog"
	APP_FILE           = "conf/app.ini"
	APP_PORT           = 5000
	APP_LOG            = "data/blog.log"
	APP_LOG_LEVEL      = "error"
	APP_DB             = "data/blog.db"
	APP_PID            = "data/blog.pid"
	APP_DEFAULT_ADMIN  = "admin"
	APP_DEFAULT_PASSWD = "12345"
)

Variables

This section is empty.

Functions

func RedisSetting

func RedisSetting(config *Cfg, c *ini.File)

func SaveConfig

func SaveConfig(f string) error

SaveConfig 配置序列化

Types

type Admin

type Admin struct {
	AdminName    string `ini:"USERNAME"`
	AdminPwd     string `ini:"PASSWD"`
	CookieMaxAge int    `ini:"PASSWD"`
	StopAdmin    bool   `ini:"STOP_ADMIN"`
}

type App

type App struct {
	PageSize           int    `ini:"PAGE_SIZE"`
	MessageSize        int    `ini:"MESSAGE_SIZE"`
	SortPostBy         string `ini:"SORT_POST_BY"`
	SortPostReverse    bool   `ini:"SORT_POST_REVERSE"`
	SortMessageBy      string `ini:"SORT_MESSAGE_BY"`
	SortMessageReverse bool   `ini:"SORT_MESSAGE_REVERSE"`
	SortCommentBy      string `ini:"SORT_COMMENT_BY"`
	SortCommentReverse bool   `ini:"SORT_COMMENT_REVERSE"`
	UseContentAsAbs    bool   `ini:"USE_CONTENT_AS_ABS"`
	MaxContentLength   int    `ini:"MAX_CONTENT_LENGTH"`
	CustomEmptyAbs     string `ini:"CUSTOM_EMPTY_ABS"`
	FakeStaticUrl      bool   `ini:"FAKE_STATIC_URL"`
	ZhuanLanId         bool   `ini:"ZHUANLAN_ID"`
	JwtSecret          string `ini:"JWT_SECRET"`
	AppRefer           string `ini:"APP_REFER"`
	AppHost            string `ini:"APP_HOST"`
	AppDomain          string `ini:"APP_DOMAIN"`
	AllowIE            bool   `ini:"APP_ALLOW_IE"`
}

type Cfg

type Cfg struct {
	RunMode string

	HTTPPort     int
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	Cluster      bool
	StaticRouter bool
	HideDBLog    bool

	PageSize           int
	MessageSize        int
	SortPostBy         string
	SortPostReverse    bool
	SortMessageBy      string
	SortMessageReverse bool
	SortCommentBy      string
	SortCommentReverse bool
	UseContentAsAbs    bool
	MaxContentLength   int
	CustomEmptyAbs     string
	FakeStaticUrl      bool
	ZhuanLanId         bool
	JwtSecret          string
	AppRefer           string
	AppHost            string
	AppDomain          string
	AllowIE            bool

	UvFlag         bool
	SimpleAuthFlag bool
	CORSFlag       bool
	PostViewFlag   bool
	UseRedis       bool
	TryFile        bool
	TryFileIndex   string

	AdminName    string
	AdminPwd     string
	CookieMaxAge int
	StopAdmin    bool

	DB               string
	MySQLType        string
	MySQLHost        string
	MySQLUserName    string
	MySQLPassWd      string
	MySQLName        string
	MySQLTablePrefix string

	RedisHost    string
	Password     string
	MaxIdle      int
	MaxActive    int
	IdleTimeout  time.Duration
	Expires      int
	PostsTimeout int

	AppName      string
	APPPid       string
	APPLog       string
	APPLogLevel  string
	APPLogFile   string
	APPLogEnable bool
}

func InitCfg

func InitCfg(p string) (Cfg, error)

防止重复引用 使用初始化加载方式 err分为读取失败 初始化失败 p不为空时优先判断是否存在 不存在会直接退出 这个操作不会触发配置的自动生成

type Middle

type Middle struct {
	UvFlag         bool   `ini:"UV"`
	SimpleAuthFlag bool   `ini:"SIMPLEAUTH"`
	CORSFlag       bool   `ini:"CORS"`
	PostViewFlag   bool   `ini:"POSTVIEW"`
	UseRedis       bool   `ini:"USEREDIS"`
	TryFile        bool   `ini:"TRY_FILE"`
	TryFileIndex   string `ini:"TRY_FILE_INDEX"`
}

type Mode

type Mode struct {
	RunMode string `ini:"RUN_MODE"`
}

type Mysql

type Mysql struct {
	MySQLType        string `ini:"TYPE"`
	MySQLHost        string `ini:"USER"`
	MySQLUserName    string `ini:"PASSWORD"`
	MySQLPassWd      string `ini:"HOST"`
	MySQLName        string `ini:"NAME"`
	MySQLTablePrefix string `ini:"TABLE_PREFIX"`
}

type Redis

type Redis struct {
	RedisHost    string        `ini:"Host"`
	Password     string        `ini:"Password"`
	MaxIdle      int           `ini:"MaxIdle"`
	MaxActive    int           `ini:"MaxActive"`
	IdleTimeout  time.Duration `ini:"IdleTimeout"`
	Expires      int           `ini:"EXPIRES"`
	PostsTimeout int           `ini:"POSTSTIMEOUT"`
}

type Run

type Run struct {
	AppName      string `ini:"APP_NAME"`
	APPPid       string `ini:"APP_PID"`
	APPLog       string `ini:"APP_LOG"`
	APPLogLevel  string `ini:"APP_LOG_LEVEL"`
	APPLogFile   string `ini:"APP_LOG_FILE"`
	APPLogEnable bool   `ini:"APP_LOG_ENABLE"`
}

type Server

type Server struct {
	HTTPPort     int           `ini:"HTTP_PORT"`
	ReadTimeout  time.Duration `ini:"READ_TIMEOUT"`
	WriteTimeout time.Duration `ini:"WRITE_TIMEOUT"`
	Cluster      bool          `ini:"CLUSTER"`
	StaticRouter bool          `ini:"STATIC_ROUTER"`
	HideDBLog    bool          `ini:"HIDE_DB_LOG"`
}

type Sqlite

type Sqlite struct {
	DB string `ini:"DB"`
}

Jump to

Keyboard shortcuts

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