config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathRoot     = "/"
	PathBackend  = "/admin"
	PathAPI      = "/api"
	PathArticle  = "/article"
	PathCategory = "/category"
	PathTag      = "/tag"
	PathSubject  = "/subject"
	PathArchives = "/archives"

	PathRSS     = "/rss"
	PathSiteMap = "/sitemap.xml"
	PathRobots  = "/robots.txt"
	PathFavicon = "/favicon.ico"
)

router path config

View Source
const (
	StaticPathRoot  = ""
	StaticPathTheme = "theme"
)

static path config

View Source
const (
	// UploadPath defines the media file save path uri
	UploadPath = "/uploads/"
	// savePath defines the use avatar saving path
	UploadUserAvatarPath = "/uploads/users/"
)

upload path config

Variables

View Source
var (
	Server *ServerConfig
	Safety *SafetyConfig
	Log    *LogConfig
	Db     *DbConfig
)

Functions

func InitConfig

func InitConfig(cfg string) error

NewConfig set up viper config and return a Config struct instance

func StaticPath

func StaticPath(Path string) string

StaticPath change path to static path base on the StaticPathRoot

func TimeLoc

func TimeLoc() *time.Location

TimeLoc sets the time zone location

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config instance struct of config

type DbConfig

type DbConfig struct {
	DbType       string `mapstructure:"db_type"`
	Name         string `mapstructure:"name"`
	Addr         string `mapstructure:"addr"`
	Username     string `mapstructure:"username"`
	Password     string `mapstructure:"password"`
	MaxIdleConns int    `mapstructure:"max_idle_conns"`
	MaxOpenConns int    `mapstructure:"max_open_conns"`
}

type LogConfig

type LogConfig struct {
	LoggerFileInfo   string `mapstructure:"logger_file_info"`
	LoggerFileError  string `mapstructure:"logger_file_error"`
	LoggerMaxSize    int    `mapstructure:"logger_max_size"`
	LoggerMaxBackups int    `mapstructure:"logger_max_backups"`
	LoggerMaxAge     int    `mapstructure:"logger_max_age"`
}

type SafetyConfig

type SafetyConfig struct {
	JwtSecret string `mapstructure:"jwt_secret"`
}

type ServerConfig

type ServerConfig struct {
	Runmode    string `mapstructure:"runmode"`
	Name       string `mapstructure:"name"`
	HttpPort   string `mapstructure:"http_port"`
	HttpsOpen  bool   `mapstructure:"https_open"`
	HttpsPort  string `mapstructure:"https_port"`
	TlsCert    string `mapstructure:"tls_cert"`
	TlsKey     string `mapstructure:"tls_key"`
	PingUrl    string `mapstructure:"ping_url"`
	PingMaxNum int    `mapstructure:"ping_max_num"`
}

Jump to

Keyboard shortcuts

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