config

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheOptionPrefix key prefix for option cache
	CacheOptionPrefix = "PUTI_OPTION_"

	// CachePostCounterKey key of post counter cache, store all post's count number as a map
	CachePostCounterKey = "PUTI_POST_VIEWS_CACHE"
	// CachePostCounterIPPoolKeyPrefix key prefix, IP Pool was be designed as a single key/value cache
	CachePostCounterIPPoolKeyPrefix = "PUTI_POST_VIEWS_CACHE_IP_"

	// CachePageDetailPrefix key prefix for page cache
	CachePageDetailPrefix = "PUTI_PAGE_"

	// CacheArticleDetailPrefix key prefix for article cache
	CacheArticleDetailPrefix = "PUTI_ARTICLE_"

	// CacheKnowledgeInfoPrefix key prefix for knowledge info
	CacheKnowledgeInfoPrefix = "PUTI_K_"
	// CacheKnowledgeItemListPrefix key prefix for knowledge item list
	CacheKnowledgeItemListPrefix = "PUTI_KITEM_"
	// CacheKnowledgeItemContentPrefix key prefix for knowledge item content
	CacheKnowledgeItemContentPrefix = "PUTI_KITEM_CONTENT_"
)
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"`
	AutoCert   bool   `mapstructure:"auto_cert"`
	TlsCert    string `mapstructure:"tls_cert"`
	TlsKey     string `mapstructure:"tls_key"`
	PutiDomain string `mapstructure:"puti_domain"`
}

Jump to

Keyboard shortcuts

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