settings

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySqlDbType    string = "mysql"
	PostgresDbType string = "postgres"
	Sqlite3DbType  string = "sqlite3"
)

Database types

View Source
const (
	OpenStreetMapProvider                  string = "openstreetmap"
	OpenStreetMapHumanitarianStyleProvider string = "openstreetmap_humanitarian"
	OpenTopoMapProvider                    string = "opentopomap"
	OPNVKarteMapProvider                   string = "opnvkarte"
	CyclOSMMapProvider                     string = "cyclosm"
	GoogleMapProvider                      string = "googlemap"
	TomTomMapProvider                      string = "tomtom"
	BaiduMapProvider                       string = "baidumap"
	AmapProvider                           string = "amap"
)

Map provider types

View Source
const (
	AmapSecurityVerificationInternalProxyMethod string = "internal_proxy"
	AmapSecurityVerificationExternalProxyMethod string = "external_proxy"
	AmapSecurityVerificationPlainTextMethod     string = "plain_text"
)

Amap security verification method

View Source
const (
	EuroCentralBankDataSource              string = "euro_central_bank"
	BankOfCanadaDataSource                 string = "bank_of_canada"
	ReserveBankOfAustraliaDataSource       string = "reserve_bank_of_australia"
	CzechNationalBankDataSource            string = "czech_national_bank"
	NationalBankOfPolandDataSource         string = "national_bank_of_poland"
	MonetaryAuthorityOfSingaporeDataSource string = "monetary_authority_of_singapore"
)

Exchange rates data source types

View Source
const (
	GravatarProvider string = "gravatar"
)

User avatar provider types

View Source
const (
	InternalUuidGeneratorType string = "internal"
)

Uuid generator types

Variables

View Source
var (
	Version    string
	CommitHash string
	Container  = &ConfigContainer{}
)

Initialize a config container singleton instance

Functions

func GetDefaultConfigFilePath

func GetDefaultConfigFilePath() (string, error)

GetDefaultConfigFilePath returns the defaule config file path

func SetCurrentConfig

func SetCurrentConfig(config *Config)

SetCurrentConfig sets the current config by a given config

Types

type Config

type Config struct {
	// Global
	AppName     string
	Mode        SystemMode
	WorkingPath string

	// Server
	Protocol Scheme
	HttpAddr string
	HttpPort uint16

	Domain  string
	RootUrl string

	CertFile    string
	CertKeyFile string

	UnixSocketPath string

	StaticRootPath string

	EnableGZip       bool
	EnableRequestLog bool

	// Database
	DatabaseConfig     *DatabaseConfig
	EnableQueryLog     bool
	AutoUpdateDatabase bool

	// Mail
	EnableSMTP bool
	SMTPConfig *SMTPConfig

	// Log
	LogModes         []string
	EnableConsoleLog bool
	EnableFileLog    bool

	LogLevel    Level
	FileLogPath string

	// Uuid
	UuidGeneratorType string
	UuidServerId      uint8

	// Secret
	SecretKey                             string
	EnableTwoFactor                       bool
	TokenExpiredTime                      uint32
	TokenExpiredTimeDuration              time.Duration
	TemporaryTokenExpiredTime             uint32
	TemporaryTokenExpiredTimeDuration     time.Duration
	EmailVerifyTokenExpiredTime           uint32
	EmailVerifyTokenExpiredTimeDuration   time.Duration
	PasswordResetTokenExpiredTime         uint32
	PasswordResetTokenExpiredTimeDuration time.Duration
	EnableRequestIdHeader                 bool

	// User
	EnableUserRegister               bool
	EnableUserVerifyEmail            bool
	EnableUserForceVerifyEmail       bool
	EnableUserForgetPassword         bool
	ForgetPasswordRequireVerifyEmail bool
	AvatarProvider                   string

	// Data
	EnableDataExport bool

	// Map
	MapProvider                    string
	TomTomMapAPIKey                string
	GoogleMapAPIKey                string
	BaiduMapAK                     string
	AmapApplicationKey             string
	AmapSecurityVerificationMethod string
	AmapApplicationSecret          string
	AmapApiExternalProxyUrl        string
	EnableMapDataFetchProxy        bool

	// Exchange Rates
	ExchangeRatesDataSource     string
	ExchangeRatesRequestTimeout uint32
	ExchangeRatesSkipTLSVerify  bool
}

Config represents the global setting config

func LoadConfiguration

func LoadConfiguration(configFilePath string) (*Config, error)

LoadConfiguration loads setting config from given config file path

type ConfigContainer

type ConfigContainer struct {
	Current *Config
}

ConfigContainer contains the current setting config

type DatabaseConfig

type DatabaseConfig struct {
	DatabaseType     string
	DatabaseHost     string
	DatabaseName     string
	DatabaseUser     string
	DatabasePassword string

	DatabaseSSLMode string

	DatabasePath string

	MaxIdleConnection     uint16
	MaxOpenConnection     uint16
	ConnectionMaxLifeTime uint32
}

DatabaseConfig represents the database setting config

type Level

type Level string

Level represents log level

const (
	LOGLEVEL_DEBUG Level = "debug"
	LOGLEVEL_INFO  Level = "info"
	LOGLEVEL_WARN  Level = "warn"
	LOGLEVEL_ERROR Level = "error"
)

Log levels

type SMTPConfig added in v0.4.0

type SMTPConfig struct {
	SMTPHost          string
	SMTPUser          string
	SMTPPasswd        string
	SMTPSkipTLSVerify bool
	FromAddress       string
}

SMTPConfig represents the SMTP setting config

type Scheme

type Scheme string

Scheme represents how the web backend service exposes

const (
	SCHEME_HTTP   Scheme = "http"
	SCHEME_HTTPS  Scheme = "https"
	SCHEME_SOCKET Scheme = "socket"
)

Scheme types

type SystemMode

type SystemMode string

SystemMode represents running mode of system

const (
	MODE_DEVELOPMENT SystemMode = "development"
	MODE_PRODUCTION  SystemMode = "production"
)

System running modes

Jump to

Keyboard shortcuts

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