config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvTest is a const value of test environment.
	EnvTest = "test"
	// EnvLocal is a const value of local environment.
	EnvLocal = "local"
	// EnvProd is a const value of production environment.
	EnvProd = "prod"

	// DriverMysql is a const value of mysql driver.
	DriverMysql = "mysql"
	// DriverSqlite is a const value of sqlite driver.
	DriverSqlite = "sqlite"
	// DriverPostgresql is a const value of postgresql driver.
	DriverPostgresql = "postgresql"
	// DriverMssql is a const value of mssql driver.
	DriverMssql = "mssql"
)

Variables

This section is empty.

Functions

func AssertPrefix added in v1.3.0

func AssertPrefix() string

AssertPrefix return the prefix of assert.

func GetAccessLogOff added in v1.3.0

func GetAccessLogOff() bool

func GetAccessLogPath added in v1.3.0

func GetAccessLogPath() string

func GetAllowDelOperationLog added in v1.3.0

func GetAllowDelOperationLog() bool

func GetAppID added in v1.3.0

func GetAppID() string

func GetAssetRootPath added in v1.3.0

func GetAssetRootPath() string

func GetAssetUrl added in v1.3.0

func GetAssetUrl() string

func GetAuthUserTable added in v1.3.0

func GetAuthUserTable() string

func GetColorScheme added in v1.3.0

func GetColorScheme() string

func GetCustom403HTML added in v1.3.0

func GetCustom403HTML() template.HTML

func GetCustom404HTML added in v1.3.0

func GetCustom404HTML() template.HTML

func GetCustom500HTML added in v1.3.0

func GetCustom500HTML() template.HTML

func GetCustomFootHtml added in v1.3.0

func GetCustomFootHtml() template.HTML

func GetCustomHeadHtml added in v1.3.0

func GetCustomHeadHtml() template.HTML

func GetDebug added in v1.3.0

func GetDebug() bool

func GetDomain added in v1.3.0

func GetDomain() string

func GetEnv added in v1.3.0

func GetEnv() string

func GetErrorLogOff added in v1.3.0

func GetErrorLogOff() bool

func GetErrorLogPath added in v1.3.0

func GetErrorLogPath() string

func GetExcludeThemeComponents added in v1.3.0

func GetExcludeThemeComponents() []string

func GetExtra added in v1.3.0

func GetExtra() map[string]interface{}

func GetFooterInfo added in v1.3.0

func GetFooterInfo() template.HTML

func GetHideVisitorUserCenterEntrance added in v1.3.0

func GetHideVisitorUserCenterEntrance() bool

func GetIndexURL added in v1.3.0

func GetIndexURL() string

GetIndexURL get the index url with prefix.

func GetIndexUrl added in v1.3.0

func GetIndexUrl() string

func GetInfoLogOff added in v1.3.0

func GetInfoLogOff() bool

func GetInfoLogPath added in v1.3.0

func GetInfoLogPath() string

func GetLanguage added in v1.3.0

func GetLanguage() string
func GetLoginLogo() template.HTML

func GetLoginTitle added in v1.3.0

func GetLoginTitle() string

func GetLoginUrl added in v1.3.0

func GetLoginUrl() string
func GetLogo() template.HTML
func GetMiniLogo() template.HTML

func GetNoLimitLoginIP added in v1.3.0

func GetNoLimitLoginIP() bool

func GetOpenAdminApi added in v1.3.0

func GetOpenAdminApi() bool

func GetOperationLogOff added in v1.3.0

func GetOperationLogOff() bool

func GetSessionLifeTime added in v1.3.0

func GetSessionLifeTime() int

func GetSiteOff added in v1.3.0

func GetSiteOff() bool

func GetSqlLog added in v1.3.0

func GetSqlLog() bool

func GetTheme added in v1.3.0

func GetTheme() string

func GetTitle added in v1.3.0

func GetTitle() string

func GetUrlPrefix added in v1.3.0

func GetUrlPrefix() string

func IsNotProductionEnvironment added in v1.3.0

func IsNotProductionEnvironment() bool

IsNotProductionEnvironment check the environment if it is not production.

func IsProductionEnvironment added in v1.3.0

func IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func Prefix added in v1.3.0

func Prefix() string

Prefix return the prefix.

func PrefixFixSlash added in v1.3.0

func PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func URLRemovePrefix added in v1.3.0

func URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func Url added in v1.3.0

func Url(suffix string) string

Types

type Config

type Config struct {
	// An map supports multi database connection. The first
	// element of Databases is the default connection. See the
	// file connection.go.
	Databases DatabaseList `json:"database,omitempty" yaml:"database,omitempty" ini:"database,omitempty"`

	// The application unique ID. Once generated, don't modify.
	AppID string `json:"app_id,omitempty" yaml:"app_id,omitempty" ini:"app_id,omitempty"`

	// The cookie domain used in the auth modules. see
	// the session.go.
	Domain string `json:"domain,omitempty" yaml:"domain,omitempty" ini:"domain,omitempty"`

	// Used to set as the localize language which show in the
	// interface.
	Language string `json:"language,omitempty" yaml:"language,omitempty" ini:"language,omitempty"`

	// The global url prefix.
	UrlPrefix string `json:"prefix,omitempty" yaml:"prefix,omitempty" ini:"prefix,omitempty"`

	// The theme name of template.
	Theme string `json:"theme,omitempty" yaml:"theme,omitempty" ini:"theme,omitempty"`

	// The path where files will be stored into.
	Store Store `json:"store,omitempty" yaml:"store,omitempty" ini:"store,omitempty"`

	// The title of web page.
	Title string `json:"title,omitempty" yaml:"title,omitempty" ini:"title,omitempty"`

	Logo template.HTML `json:"logo,omitempty" yaml:"logo,omitempty" ini:"logo,omitempty"`

	MiniLogo template.HTML `json:"mini_logo,omitempty" yaml:"mini_logo,omitempty" ini:"mini_logo,omitempty"`

	// The url redirect to after login.
	IndexUrl string `json:"index,omitempty" yaml:"index,omitempty" ini:"index,omitempty"`

	// Login page URL
	LoginUrl string `json:"login_url,omitempty" yaml:"login_url,omitempty" ini:"login_url,omitempty"`

	// Debug mode
	Debug bool `json:"debug,omitempty" yaml:"debug,omitempty" ini:"debug,omitempty"`

	// Env is the environment,which maybe local,test,prod.
	Env string `json:"env,omitempty" yaml:"env,omitempty" ini:"env,omitempty"`

	// Info log path.
	InfoLogPath string `json:"info_log,omitempty" yaml:"info_log,omitempty" ini:"info_log,omitempty"`

	// Error log path.
	ErrorLogPath string `json:"error_log,omitempty" yaml:"error_log,omitempty" ini:"error_log,omitempty"`

	// Access log path.
	AccessLogPath string `json:"access_log,omitempty" yaml:"access_log,omitempty" ini:"access_log,omitempty"`

	// Access assets log off
	AccessAssetsLogOff bool `json:"access_assets_log_off,omitempty" yaml:"access_assets_log_off,omitempty" ini:"access_assets_log_off,omitempty"`

	// Sql operator record log switch.
	SqlLog bool `json:"sql_log,omitempty" yaml:"sql_log,omitempty" ini:"sql_log,omitempty"`

	AccessLogOff bool `json:"access_log_off,omitempty" yaml:"access_log_off,omitempty" ini:"access_log_off,omitempty"`
	InfoLogOff   bool `json:"info_log_off,omitempty" yaml:"info_log_off,omitempty" ini:"info_log_off,omitempty"`
	ErrorLogOff  bool `json:"error_log_off,omitempty" yaml:"error_log_off,omitempty" ini:"error_log_off,omitempty"`

	Logger Logger `json:"logger,omitempty" yaml:"logger,omitempty" ini:"logger,omitempty"`

	// Color scheme.
	ColorScheme string `json:"color_scheme,omitempty" yaml:"color_scheme,omitempty" ini:"color_scheme,omitempty"`

	// Session valid time duration,units are seconds. Default 7200.
	SessionLifeTime int `json:"session_life_time,omitempty" yaml:"session_life_time,omitempty" ini:"session_life_time,omitempty"`

	// Assets visit link.
	AssetUrl string `json:"asset_url,omitempty" yaml:"asset_url,omitempty" ini:"asset_url,omitempty"`

	// File upload engine,default "local"
	FileUploadEngine FileUploadEngine `json:"file_upload_engine,omitempty" yaml:"file_upload_engine,omitempty" ini:"file_upload_engine,omitempty"`

	// Custom html in the tag head.
	CustomHeadHtml template.HTML `json:"custom_head_html,omitempty" yaml:"custom_head_html,omitempty" ini:"custom_head_html,omitempty"`

	// Custom html after body.
	CustomFootHtml template.HTML `json:"custom_foot_html,omitempty" yaml:"custom_foot_html,omitempty" ini:"custom_foot_html,omitempty"`

	// Footer Info html
	FooterInfo template.HTML `json:"footer_info,omitempty" yaml:"footer_info,omitempty" ini:"footer_info,omitempty"`

	// Login page title
	LoginTitle string `json:"login_title,omitempty" yaml:"login_title,omitempty" ini:"login_title,omitempty"`

	LoginLogo template.HTML `json:"login_logo,omitempty" yaml:"login_logo,omitempty" ini:"login_logo,omitempty"`

	// Auth user table
	AuthUserTable string `json:"auth_user_table,omitempty" yaml:"auth_user_table,omitempty" ini:"auth_user_table,omitempty"`

	// Extra config info
	Extra ExtraInfo `json:"extra,omitempty" yaml:"extra,omitempty" ini:"extra,omitempty"`

	// Page animation
	Animation PageAnimation `json:"animation,omitempty" yaml:"animation,omitempty" ini:"animation,omitempty"`

	// Limit login with different IPs
	NoLimitLoginIP bool `json:"no_limit_login_ip,omitempty" yaml:"no_limit_login_ip,omitempty" ini:"no_limit_login_ip,omitempty"`

	// When site off is true, website will be closed
	SiteOff bool `json:"site_off,omitempty" yaml:"site_off,omitempty" ini:"site_off,omitempty"`

	// Hide config center entrance flag
	HideConfigCenterEntrance bool `` /* 133-byte string literal not displayed */

	// Hide app info entrance flag
	HideAppInfoEntrance bool `json:"hide_app_info_entrance,omitempty" yaml:"hide_app_info_entrance,omitempty" ini:"hide_app_info_entrance,omitempty"`

	// Hide tool entrance flag
	HideToolEntrance bool `json:"hide_tool_entrance,omitempty" yaml:"hide_tool_entrance,omitempty" ini:"hide_tool_entrance,omitempty"`

	HidePluginEntrance bool `json:"hide_plugin_entrance,omitempty" yaml:"hide_plugin_entrance,omitempty" ini:"hide_plugin_entrance,omitempty"`

	Custom404HTML template.HTML `json:"custom_404_html,omitempty" yaml:"custom_404_html,omitempty" ini:"custom_404_html,omitempty"`

	Custom403HTML template.HTML `json:"custom_403_html,omitempty" yaml:"custom_403_html,omitempty" ini:"custom_403_html,omitempty"`

	Custom500HTML template.HTML `json:"custom_500_html,omitempty" yaml:"custom_500_html,omitempty" ini:"custom_500_html,omitempty"`

	// Update Process Function
	UpdateProcessFn UpdateConfigProcessFn `json:"-" yaml:"-" ,omitemptyini:"-,omitempty"`

	// Is open admin plugin json api
	OpenAdminApi bool `json:"open_admin_api,omitempty" yaml:"open_admin_api,omitempty" ini:"open_admin_api,omitempty"`

	HideVisitorUserCenterEntrance bool `` /* 151-byte string literal not displayed */

	ExcludeThemeComponents []string `json:"exclude_theme_components,omitempty" yaml:"exclude_theme_components,omitempty" ini:"exclude_theme_components,omitempty"`

	BootstrapFilePath string `json:"bootstrap_file_path,omitempty" yaml:"bootstrap_file_path,omitempty" ini:"bootstrap_file_path,omitempty"`

	GoModFilePath string `json:"go_mod_file_path,omitempty" yaml:"go_mod_file_path,omitempty" ini:"go_mod_file_path,omitempty"`

	AllowDelOperationLog bool `json:"allow_del_operation_log,omitempty" yaml:"allow_del_operation_log,omitempty" ini:"allow_del_operation_log,omitempty"`

	OperationLogOff bool `json:"operation_log_off,omitempty" yaml:"operation_log_off,omitempty" ini:"operation_log_off,omitempty"`

	AssetRootPath string `json:"asset_root_path,omitempty" yaml:"asset_root_path,omitempty" ini:"asset_root_path,omitempty"`
	// contains filtered or unexported fields
}

Config type is the global config of goAdmin. It will be initialized in the engine.

func Get

func Get() *Config

Get gets the config.

func GetService added in v1.3.0

func GetService(s interface{}) *Config

func ReadFromINI added in v1.3.0

func ReadFromINI(path string) Config

ReadFromINI read the Config from a INI file.

func ReadFromJson added in v1.3.0

func ReadFromJson(path string) Config

ReadFromJson read the Config from a JSON file.

func ReadFromYaml added in v1.3.0

func ReadFromYaml(path string) Config

ReadFromYaml read the Config from a YAML file.

func Set

func Set(cfg *Config) *Config

Set sets the config.

func SetDefault added in v1.3.0

func SetDefault(cfg *Config) *Config

func (*Config) AddUpdateProcessFn added in v1.3.0

func (c *Config) AddUpdateProcessFn(fn UpdateConfigProcessFn) *Config

func (*Config) AssertPrefix added in v1.3.0

func (c *Config) AssertPrefix() string

AssertPrefix return the prefix of assert.

func (*Config) Copy added in v1.3.0

func (c *Config) Copy() *Config

func (*Config) EraseSens added in v1.3.0

func (c *Config) EraseSens() *Config

eraseSens erase sensitive info.

func (*Config) GetIndexURL added in v1.3.0

func (c *Config) GetIndexURL() string

GetIndexURL get the index url with prefix.

func (*Config) Index added in v1.3.0

func (c *Config) Index() string

Index return the index url without prefix.

func (*Config) IsLocalEnvironment added in v1.3.0

func (c *Config) IsLocalEnvironment() bool

IsLocalEnvironment check the environment if it is local.

func (*Config) IsNotProductionEnvironment added in v1.3.0

func (c *Config) IsNotProductionEnvironment() bool

IsNotProductionEnvironment check the environment if it is not production.

func (*Config) IsProductionEnvironment added in v1.3.0

func (c *Config) IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func (*Config) IsTestEnvironment added in v1.3.0

func (c *Config) IsTestEnvironment() bool

IsTestEnvironment check the environment if it is test.

func (*Config) Prefix added in v1.3.0

func (c *Config) Prefix() string

Prefix return the prefix.

func (*Config) PrefixFixSlash added in v1.3.0

func (c *Config) PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func (*Config) ToMap added in v1.3.0

func (c *Config) ToMap() map[string]string

func (*Config) URLRemovePrefix added in v1.3.0

func (c *Config) URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func (*Config) Update added in v1.3.0

func (c *Config) Update(m map[string]string) error

func (*Config) Url added in v1.3.0

func (c *Config) Url(suffix string) string

Url get url with the given suffix.

type Database

type Database struct {
	Host       string            `json:"host,omitempty" yaml:"host,omitempty" ini:"host,omitempty"`
	Port       string            `json:"port,omitempty" yaml:"port,omitempty" ini:"port,omitempty"`
	User       string            `json:"user,omitempty" yaml:"user,omitempty" ini:"user,omitempty"`
	Pwd        string            `json:"pwd,omitempty" yaml:"pwd,omitempty" ini:"pwd,omitempty"`
	Name       string            `json:"name,omitempty" yaml:"name,omitempty" ini:"name,omitempty"`
	MaxIdleCon int               `json:"max_idle_con,omitempty" yaml:"max_idle_con,omitempty" ini:"max_idle_con,omitempty"`
	MaxOpenCon int               `json:"max_open_con,omitempty" yaml:"max_open_con,omitempty" ini:"max_open_con,omitempty"`
	Driver     string            `json:"driver,omitempty" yaml:"driver,omitempty" ini:"driver,omitempty"`
	File       string            `json:"file,omitempty" yaml:"file,omitempty" ini:"file,omitempty"`
	Dsn        string            `json:"dsn,omitempty" yaml:"dsn,omitempty" ini:"dsn,omitempty"`
	Params     map[string]string `json:"params,omitempty" yaml:"params,omitempty" ini:"params,omitempty"`
}

Database is a type of database connection config.

Because a little difference of different database driver. The Config has multiple options but may not be used. Such as the sqlite driver only use the File option which can be ignored when the driver is mysql.

If the Dsn is configured, when driver is mysql/postgresql/ mssql, the other configurations will be ignored, except for MaxIdleCon and MaxOpenCon.

func (Database) GetDSN added in v1.3.0

func (d Database) GetDSN() string

func (Database) ParamStr added in v1.3.0

func (d Database) ParamStr() string

type DatabaseList added in v1.3.0

type DatabaseList map[string]Database

DatabaseList is a map of Database.

func GetDatabaseListFromJSON added in v1.3.0

func GetDatabaseListFromJSON(m string) DatabaseList

func GetDatabases added in v1.3.0

func GetDatabases() DatabaseList

func (DatabaseList) Add added in v1.3.0

func (d DatabaseList) Add(key string, db Database)

Add add a Database to the DatabaseList.

func (DatabaseList) Connections added in v1.3.0

func (d DatabaseList) Connections() []string

func (DatabaseList) Copy added in v1.3.0

func (d DatabaseList) Copy() DatabaseList

func (DatabaseList) GetDefault added in v1.3.0

func (d DatabaseList) GetDefault() Database

GetDefault get the default Database.

func (DatabaseList) GroupByDriver added in v1.3.0

func (d DatabaseList) GroupByDriver() map[string]DatabaseList

GroupByDriver group the Databases with the drivers.

func (DatabaseList) JSON added in v1.3.0

func (d DatabaseList) JSON() string

type EncoderCfg added in v1.3.0

type EncoderCfg struct {
	TimeKey       string `json:"time_key,omitempty" yaml:"time_key,omitempty" ini:"time_key,omitempty"`
	LevelKey      string `json:"level_key,omitempty" yaml:"level_key,omitempty" ini:"level_key,omitempty"`
	NameKey       string `json:"name_key,omitempty" yaml:"name_key,omitempty" ini:"name_key,omitempty"`
	CallerKey     string `json:"caller_key,omitempty" yaml:"caller_key,omitempty" ini:"caller_key,omitempty"`
	MessageKey    string `json:"message_key,omitempty" yaml:"message_key,omitempty" ini:"message_key,omitempty"`
	StacktraceKey string `json:"stacktrace_key,omitempty" yaml:"stacktrace_key,omitempty" ini:"stacktrace_key,omitempty"`
	Level         string `json:"level,omitempty" yaml:"level,omitempty" ini:"level,omitempty"`
	Time          string `json:"time,omitempty" yaml:"time,omitempty" ini:"time,omitempty"`
	Duration      string `json:"duration,omitempty" yaml:"duration,omitempty" ini:"duration,omitempty"`
	Caller        string `json:"caller,omitempty" yaml:"caller,omitempty" ini:"caller,omitempty"`
	Encoding      string `json:"encoding,omitempty" yaml:"encoding,omitempty" ini:"encoding,omitempty"`
}

type ExtraInfo added in v1.3.0

type ExtraInfo map[string]interface{}

type FileUploadEngine added in v1.3.0

type FileUploadEngine struct {
	Name   string                 `json:"name,omitempty" yaml:"name,omitempty" ini:"name,omitempty"`
	Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty" ini:"config,omitempty"`
}

FileUploadEngine is a file upload engine.

func GetFileUploadEngine added in v1.3.0

func GetFileUploadEngine() FileUploadEngine

func GetFileUploadEngineFromJSON added in v1.3.0

func GetFileUploadEngineFromJSON(m string) FileUploadEngine

func (FileUploadEngine) JSON added in v1.3.0

func (f FileUploadEngine) JSON() string

type Logger added in v1.3.0

type Logger struct {
	Encoder EncoderCfg `json:"encoder,omitempty" yaml:"encoder,omitempty" ini:"encoder,omitempty"`
	Rotate  RotateCfg  `json:"rotate,omitempty" yaml:"rotate,omitempty" ini:"rotate,omitempty"`
	Level   int8       `json:"level,omitempty" yaml:"level,omitempty" ini:"level,omitempty"`
}

type PageAnimation added in v1.3.0

type PageAnimation struct {
	Type     string  `json:"type,omitempty" yaml:"type,omitempty" ini:"type,omitempty"`
	Duration float32 `json:"duration,omitempty" yaml:"duration,omitempty" ini:"duration,omitempty"`
	Delay    float32 `json:"delay,omitempty" yaml:"delay,omitempty" ini:"delay,omitempty"`
}

see more: https://daneden.github.io/animate.css/

func GetAnimation added in v1.3.0

func GetAnimation() PageAnimation

func (PageAnimation) JSON added in v1.3.0

func (p PageAnimation) JSON() string

type RotateCfg added in v1.3.0

type RotateCfg struct {
	MaxSize    int  `json:"max_size,omitempty" yaml:"max_size,omitempty" ini:"max_size,omitempty"`
	MaxBackups int  `json:"max_backups,omitempty" yaml:"max_backups,omitempty" ini:"max_backups,omitempty"`
	MaxAge     int  `json:"max_age,omitempty" yaml:"max_age,omitempty" ini:"max_age,omitempty"`
	Compress   bool `json:"compress,omitempty" yaml:"compress,omitempty" ini:"compress,omitempty"`
}

type Service added in v1.3.0

type Service struct {
	C *Config
}

func SrvWithConfig added in v1.3.0

func SrvWithConfig(c *Config) *Service

func (*Service) Name added in v1.3.0

func (s *Service) Name() string

type Store

type Store struct {
	Path   string `json:"path,omitempty" yaml:"path,omitempty" ini:"path,omitempty"`
	Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty" ini:"prefix,omitempty"`
}

Store is the file store config. Path is the local store path. and prefix is the url prefix used to visit it.

func GetStore added in v1.3.0

func GetStore() Store

func GetStoreFromJSON added in v1.3.0

func GetStoreFromJSON(m string) Store

func (Store) JSON added in v1.3.0

func (s Store) JSON() string

func (Store) URL added in v1.3.0

func (s Store) URL(suffix string) string

type UpdateConfigProcessFn added in v1.3.0

type UpdateConfigProcessFn func(values form.Values) (form.Values, error)

Jump to

Keyboard shortcuts

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